Last active
April 24, 2017 23:31
-
-
Save senthilp/5ffcc4370f86da04ab89dcec42531c7a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class MyCarousel extends HTMLElement { | |
static get observedAttributes() { | |
return ['index']; | |
} | |
// Called anytime the 'index' attribute is changed | |
attributeChangedCallback(attrName, oldVal, newVal) { | |
this[attrName] = newVal; | |
} | |
// Takes an index value | |
set index(idx) { | |
// First check if it is numeric | |
const numericIndex = parseInt(idx, 10); | |
if (isNaN(numericIndex)) { | |
return; | |
} | |
// Update the internal state | |
this._index = numericIndex; | |
/* Perform the associated DOM operations */ | |
moveCarousel(); | |
} | |
get index() { | |
return this._index; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment