Skip to content

Instantly share code, notes, and snippets.

@senthilp
Created April 12, 2017 06:43
Show Gist options
  • Save senthilp/ddeb5fd16d7cfde7bde40289ffb9ac7c to your computer and use it in GitHub Desktop.
Save senthilp/ddeb5fd16d7cfde7bde40289ffb9ac7c to your computer and use it in GitHub Desktop.
const carouselElement = document.querySelector('#carousel1');
Object.defineProperty(carouselElement, 'index', {
set(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() {
return this._index;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment