Created
April 12, 2017 06:43
-
-
Save senthilp/ddeb5fd16d7cfde7bde40289ffb9ac7c 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
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