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,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;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import HomeBtn from './DevTools/HomeBtn.es6'
|
||||
import HomeBtn from './HomeBtn/HomeBtn.es6'
|
||||
import DevTools from './DevTools/DevTools.es6'
|
||||
import Console from './Console/Console.es6'
|
||||
import Network from './Network/Network.es6'
|
||||
@@ -45,6 +45,8 @@ devTools.add(consoleTool)
|
||||
settings.separator()
|
||||
.add(devTools.config, 'activeEruda', 'Always Activated')
|
||||
.separator()
|
||||
.add(homeBtn.config, 'rememberPos', 'Remember Home Button Position')
|
||||
.separator()
|
||||
.add(devTools.config, 'transparent', 'Transparent')
|
||||
.add(devTools.config, 'halfScreen', 'Half Screen Size');
|
||||
|
||||
|
||||
@@ -2280,6 +2280,40 @@ module.exports = (function ()
|
||||
return exports;
|
||||
})({});
|
||||
|
||||
/* ------------------------------ toNum ------------------------------ */
|
||||
|
||||
var toNum = _.toNum = (function (exports)
|
||||
{
|
||||
/* Convert value to a number.
|
||||
*
|
||||
* |Name |Type |Desc |
|
||||
* |------------------------------|
|
||||
* |val |* |Value to process|
|
||||
* |return|number|Resulted number |
|
||||
*
|
||||
* ```javascript
|
||||
* toNum('5'); // -> 5
|
||||
* ```
|
||||
*/
|
||||
|
||||
exports = function (val)
|
||||
{
|
||||
if (isNum(val)) return val;
|
||||
|
||||
if (isObj(val))
|
||||
{
|
||||
var temp = isFn(val.valueOf) ? val.valueOf() : val;
|
||||
val = isObj(temp) ? (temp + '') : temp;
|
||||
}
|
||||
|
||||
if (!isStr(val)) return val === 0 ? val : +val;
|
||||
|
||||
return +val;
|
||||
};
|
||||
|
||||
return exports;
|
||||
})({});
|
||||
|
||||
/* ------------------------------ trim ------------------------------ */
|
||||
|
||||
var trim = _.trim = (function (exports)
|
||||
|
||||
Reference in New Issue
Block a user