mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-24 09:48:37 +08:00
Dev: Remember home button position
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
import util from '../lib/util'
|
||||
import Draggabilly from 'draggabilly'
|
||||
|
||||
require('./HomeBtn.scss');
|
||||
|
||||
export default class HomeBtn extends util.Emitter
|
||||
{
|
||||
constructor($parent)
|
||||
{
|
||||
super();
|
||||
this._$parent = $parent;
|
||||
|
||||
this._appendTpl();
|
||||
this._makeDraggable();
|
||||
this._setPos();
|
||||
this._bindEvent();
|
||||
}
|
||||
_appendTpl()
|
||||
{
|
||||
var $parent = this._$parent;
|
||||
|
||||
$parent.append(require('./HomeBtn.hbs')());
|
||||
|
||||
this._$el = $parent.find('.eruda-home-btn');
|
||||
}
|
||||
_setPos()
|
||||
{
|
||||
var wh = window.innerHeight,
|
||||
ww = window.innerWidth;
|
||||
|
||||
this._$el.css({
|
||||
left: ww - 50,
|
||||
top: wh - 50
|
||||
});
|
||||
}
|
||||
_bindEvent()
|
||||
{
|
||||
this._draggabilly.on('staticClick', () => this.emit('click'));
|
||||
|
||||
util.orientation.on('change', () => this._setPos());
|
||||
}
|
||||
_makeDraggable()
|
||||
{
|
||||
this._draggabilly = new Draggabilly(this._$el.get(0), {
|
||||
containment: true
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
<div class="eruda-home-btn">
|
||||
<span class="eruda-icon-cog"></span>
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
.home-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #000;
|
||||
opacity: 0.3;
|
||||
border-radius: 10px;
|
||||
position: relative;
|
||||
z-index: 1000;
|
||||
transition: opacity .3s;
|
||||
color: #fff;
|
||||
font-size: 25px;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
span {
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user