Created
March 16, 2020 03:44
-
-
Save daltonmenezes/02029830cc986543781c570f14efba99 to your computer and use it in GitHub Desktop.
Get pixel value by increment in javascript to handle element sizes
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
const pixel = ((init = 0) => { | |
let pixelValue = init | |
function increment(value) { | |
pixelValue += value | |
} | |
return { | |
getByIncrement: value => { | |
increment(value) | |
return pixelValue + 'px' | |
} | |
} | |
})() | |
console.log( | |
pixel.getByIncrement(100), // 100px | |
pixel.getByIncrement(100) // 200px | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment