Created
October 28, 2014 17:28
-
-
Save ybigus/b6357b322b06d1b6b95c 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
var womanHeightList = [155,157,160,163,165,168,170,171,173,175,178,180,183]; | |
var increaseButtonStream = $('.btn-size.add').asEventStream('click'); | |
var decreaseButtonStream = $('.btn-size.delete').asEventStream('click'); | |
var counterStream = increaseButtonStream.map(1).merge(decreaseButtonStream.map(-1)).scan(0, function (acc, x){ | |
var sum = acc + x; | |
if (sum<0) sum = womanHeightList.length-1; | |
if (sum>womanHeightList.length-1) sum = 0; | |
return sum; | |
}); | |
var counterTextStream = counterStream.map(function(value){ | |
return womanHeightList[value]; | |
}); | |
var imageHeightStream = counterStream.map(function(value){ | |
var humanHeight = womanHeightList[value] * pxPerSm; | |
return humanHeight; | |
}); | |
counterTextStream.assign($('.current-height'), 'text'); | |
imageHeightStream.assign($('.human'), 'height'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment