新增update方法,优先级高于render
This commit is contained in:
parent
fb1935e79d
commit
78d0b8ed57
|
@ -61,7 +61,7 @@ Nuclear._mixObj = function (obj) {
|
|||
parent: this.parent
|
||||
};
|
||||
this._nuclearRender(this._nuclearRenderInfo);
|
||||
|
||||
if (this.installed) this.installed();
|
||||
}
|
||||
|
||||
//加if防止子类赋值undefined,丢失父类方法
|
||||
|
@ -104,7 +104,7 @@ Nuclear._mixObj = function (obj) {
|
|||
this._nuclearId = Nuclear.getId()
|
||||
this.node.setAttribute("data-nuclearId", this._nuclearId);
|
||||
if (this.onRefresh) this.onRefresh();
|
||||
if (this.installed) this.installed();
|
||||
|
||||
item.refreshPart = this.node.querySelectorAll('*[nc-refresh]');
|
||||
this.HTML = this.node.outerHTML;
|
||||
|
||||
|
@ -141,6 +141,10 @@ Nuclear._mixObj = function (obj) {
|
|||
}
|
||||
|
||||
obj._nuclearLocalRefresh = function () {
|
||||
if (this.update) {
|
||||
this.update();
|
||||
return;
|
||||
}
|
||||
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
|
||||
item.tpl = this._nuclearTplGenerator();
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Marquee</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container"></div>
|
||||
<script src="../dist/nuclear.js"></script>
|
||||
<script type="text/javascript">
|
||||
var Marquee = Nuclear.create({
|
||||
installed: function () {
|
||||
this.scroll = this.node.querySelector(".marquee-scroll");
|
||||
this.end =-20+ parseInt(window.getComputedStyle(this.scroll)["width"])*-1;
|
||||
this.loop = setInterval(function () {
|
||||
this.option.left -= 5;
|
||||
if (this.option.left < this.end) this.option.left = this.option.width;
|
||||
}.bind(this), 100);
|
||||
},
|
||||
update: function () {
|
||||
this.scroll.style.left = this.option.left+"px";
|
||||
},
|
||||
render: function () {
|
||||
return '<div style="width:{{width}}px;overflow:hidden;position:relative;"><div style="visibility:hidden;">a核</div><div class="marquee-scroll" style="position:absolute; white-space:nowrap;left:{{left}}px;top:0;">{{content}}</div></div>';
|
||||
}
|
||||
})
|
||||
new Marquee({ width: 280, left: 280, content: "张三中了 笔记本电脑 张三中了 笔记本电脑 张三中了 笔记本电脑 张三中了 笔记本电脑 ", }, "#container");
|
||||
</script>
|
||||
<a href="https://github.com/AlloyTeam/Nuclear" target="_blank" style="position: absolute; right: 0; top: 0;">
|
||||
<img src="http://alloyteam.github.io/AlloyRenderingEngine/asset/img/github.png" alt="" />
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -42,7 +42,7 @@ Nuclear._mixObj = function (obj) {
|
|||
parent: this.parent
|
||||
};
|
||||
this._nuclearRender(this._nuclearRenderInfo);
|
||||
|
||||
if (this.installed) this.installed();
|
||||
}
|
||||
|
||||
//加if防止子类赋值undefined,丢失父类方法
|
||||
|
@ -85,7 +85,7 @@ Nuclear._mixObj = function (obj) {
|
|||
this._nuclearId = Nuclear.getId()
|
||||
this.node.setAttribute("data-nuclearId", this._nuclearId);
|
||||
if (this.onRefresh) this.onRefresh();
|
||||
if (this.installed) this.installed();
|
||||
|
||||
item.refreshPart = this.node.querySelectorAll('*[nc-refresh]');
|
||||
this.HTML = this.node.outerHTML;
|
||||
|
||||
|
@ -122,6 +122,10 @@ Nuclear._mixObj = function (obj) {
|
|||
}
|
||||
|
||||
obj._nuclearLocalRefresh = function () {
|
||||
if (this.update) {
|
||||
this.update();
|
||||
return;
|
||||
}
|
||||
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
|
||||
item.tpl = this._nuclearTplGenerator();
|
||||
|
||||
|
|
Loading…
Reference in New Issue