Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var prevItem = null;
- var nextItem = null;
- var swipeValue = APP.Device.width * 0.51;
- var cancelSwipe = false;
- var xStart = 0, xPrev = 0;
- $.createRecipeListItem = function(_item, _i, _isFirst) {
- if (!_isFirst) {
- prevItem = $.recipeInfoWrapper.getChildren()[0];
- }
- nextItem = Ti.UI.createScrollView({
- opacity: _isFirst ? 1 : 0,
- height: Ti.UI.SIZE,
- top: '0dp',
- left: OS_IOS ? '10dp' : Alloy.Globals.padding,
- right: OS_IOS ? '10dp' : Alloy.Globals.padding,
- layout: 'vertical',
- id: 'recipeInfo_MainWrapper_' + _item.id,
- globalSwipe: false
- });
- $.drawRecipeItem(_item, _i, nextItem);
- $.drawIngridientsList(_item, _i, nextItem);
- $.recipeInfoWrapper.add(nextItem);
- if (!_isFirst) {
- prevItem.animate({
- opacity: 0,
- duration: 150
- }, function () {
- while ($.recipeInfoWrapper.getChildren().length > 1) {
- $.recipeInfoWrapper.remove($.recipeInfoWrapper.getChildren()[0]);
- };
- });
- nextItem.animate({
- opacity: 1,
- duration: 150
- }, function () {
- cancelSwipe = false;
- });
- } else {
- while ($.recipeInfoWrapper.getChildren().length > 1) {
- $.recipeInfoWrapper.remove($.recipeInfoWrapper.getChildren()[0]);
- };
- }
- nextItem.addEventListener('touchstart', function(_event) {
- xStart = _event.x;
- });
- nextItem.addEventListener('touchmove', function(_event) {
- if (cancelSwipe || xPrev == _event.x) return;
- xPrev = _event.x;
- if (xStart > _event.x && (xStart - _event.x > swipeValue) && itemId != fullLength-1) {
- cancelSwipe = true;
- xStart = _event.x;
- itemId++;
- $.createRecipeListItem(recipesList[itemId], itemId);
- $.navigateInfo.text = (itemId + 1) + ' / ' + fullLength;
- } else if (xStart < _event.x && (_event.x - xStart > swipeValue) && itemId != 0) {
- cancelSwipe = true;
- xStart = _event.x;
- itemId--;
- $.createRecipeListItem(recipesList[itemId], itemId);
- $.navigateInfo.text = (itemId + 1) + ' / ' + fullLength;
- }
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement