jsyg-stdconstruct
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "jsyg-stdconstruct", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Standard constructor for writing JSYG plugins", | ||
@@ -30,4 +30,4 @@ "main": "JSYG.StdConstruct.js", | ||
"jquery": "^2.2.3", | ||
"jsyg-events": "^0.2.4" | ||
"jsyg-events": "" | ||
} | ||
} |
# JSYG.StdConstruct | ||
Standard constructor for writing JSYG plugins | ||
Standard constructor for writing [JSYG](https://github.com/YannickBochatay/JSYG) or plugins | ||
### Installation | ||
```shell | ||
npm install jsyg-stdconstruct | ||
``` | ||
### Example with es6 | ||
```javascript | ||
import StdConstruct from "jsyg-stdconstruct" | ||
export default class Blink extends StdConstruct { | ||
constructor(selector,opt) { | ||
this.onshow = null | ||
this.onhide = null | ||
this.setNode(selector) | ||
this.frequency = 1000 | ||
if (opt) this.enable(opt) | ||
} | ||
show() { | ||
this.node.style.display = "none" | ||
this.trigger("show") | ||
return this | ||
} | ||
hide() { | ||
this.node.style.display = "block" | ||
this.trigger("hide") | ||
return this | ||
} | ||
toggle() { | ||
this[ this.node.style.display == "none" ? "show" : "hide" ]() | ||
} | ||
enable(opt) { | ||
this.disable() | ||
if (opt) this.set(opt) | ||
this.interval = window.setInterval( this.toggle.bind(this), this.frequency ) | ||
this.enabled = true | ||
} | ||
disable() { | ||
if (this.interval) window.clearInterval(this.interval) | ||
this.enabled = false | ||
} | ||
} | ||
``` | ||
```javascript | ||
import Blink from "./blink" | ||
let blink = new Blink('#myElement') | ||
blink.on({ | ||
"show" : () => console.log("show") | ||
"hide" : () => console.log("hide") | ||
}) | ||
blink.enable({ | ||
frequency : 2000 | ||
}) | ||
``` | ||
If you use JSYG framework, you can register the plugin like this : | ||
```javascript | ||
let plugin = JSYG.bindPlugin(Blink) | ||
JSYG.prototype.blink = function() { plugin.apply(this,arguments); } | ||
``` | ||
Then you can use your plugin like this : | ||
```javascript | ||
let $myElmt = JSYG("#myElement") | ||
$myElmt.blink({ | ||
frequency : 2000, | ||
onshow : () => console.log("show") | ||
onhide : () => console.log("hide") | ||
}) | ||
window.setTimeout( ()=> $myElmt.blink("disable"), 10000 ) | ||
``` |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
10396
98
2
+ Addedjsyg-events@1.0.0(transitive)
- Removedjsyg-events@0.2.4(transitive)
Updatedjsyg-events@