Dev: Remember home button position

This commit is contained in:
surunzi
2016-05-03 11:16:14 +08:00
parent ac36ea97e1
commit 38d3306396
5 changed files with 37 additions and 70 deletions

View File

@@ -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
});
}
};

View File

@@ -1,3 +0,0 @@
<div class="eruda-home-btn">
<span class="eruda-icon-cog"></span>
</div>

View File

@@ -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;
}
}