-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
246 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,7 @@ | ||
Slim.tag('slim-logo', class extends Slim { | ||
|
||
|
||
get template() { return `<img slim-id="img" src="slim2.png" width="350" height="130" style="[[effect(cx,cy)]]" />`} | ||
|
||
onCreated() { | ||
document.body.addEventListener('mousemove', e => { | ||
this.cx = e.clientX | ||
this.cy = e.clientY | ||
}) | ||
} | ||
|
||
effect(x, y) { | ||
return `transform: rotate3d(${150 - y}, ${x - 150}, 0, 25deg)` | ||
} | ||
get template() { return `<img slim-id="img" src="slim2.png" width="350" height="130" />`} | ||
|
||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Slim.tag('slim-states', class extends Slim { | ||
|
||
|
||
get currentState() { | ||
return this.getAttribute('current-state') | ||
} | ||
|
||
set currentState(value) { | ||
this.setAttribute('current-state', value) | ||
this.renderChildren() | ||
} | ||
|
||
renderChildren() { | ||
let currentChildren = Array.prototype.slice.call( this.children ) | ||
for (let i = currentChildren.length - 1; i >= 0; i--) { | ||
let child = currentChildren[i] | ||
if (child.getAttribute('state') !== this.currentState) { | ||
this.hiddenChildren.appendChild(child) | ||
} | ||
} | ||
|
||
currentChildren = Array.prototype.slice.call( this.hiddenChildren.children ) | ||
for (let i = currentChildren.length - 1; i >= 0; i--) { | ||
let child = currentChildren[i] | ||
if (child.getAttribute('state') === this.currentState) { | ||
this.appendChild(child) | ||
} | ||
} | ||
} | ||
|
||
onBeforeCreated() { | ||
this.hiddenChildren = document.createElement('virtual') | ||
} | ||
|
||
onAfterRender() { | ||
this.renderChildren() | ||
} | ||
|
||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Slim.tag('slim-tabs', class extends Slim { | ||
|
||
onCreated() { | ||
this.tabs = this.getAttribute('tabs').split(',') | ||
} | ||
|
||
update() { | ||
super.update() | ||
this.findAll('slim-tab').forEach( tab => { | ||
tab.onclick = (e) => { | ||
this.states.currentState = tab.find('span').tabName | ||
} | ||
}) | ||
} | ||
|
||
}) | ||
|
||
Slim.tag('slim-tab', class extends Slim { | ||
get template() { | ||
return '<span tab-name="[[data]]" bind>[[data]] </span>' | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,11 @@ class SlimUIBase extends Slim { | |
} | ||
|
||
|
||
} | ||
|
||
class SlimModel extends Slim { | ||
|
||
get view() { | ||
return this._boundParent | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters