(value, type, duration, params)
| 559 | * - an optional parameter containing any variables that need to be passed in |
| 560 | */ |
| 561 | var setPositionProperty = function(value, type, duration, params) { |
| 562 | var animateObj, propValue; |
| 563 | // use CSS transform |
| 564 | if (slider.usingCSS) { |
| 565 | // determine the translate3d value |
| 566 | propValue = slider.settings.mode === 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)'; |
| 567 | // add the CSS transition-duration |
| 568 | el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's'); |
| 569 | if (type === 'slide') { |
| 570 | // set the property value |
| 571 | el.css(slider.animProp, propValue); |
| 572 | if (duration !== 0) { |
| 573 | // add a callback method - executes when CSS transition completes |
| 574 | el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { |
| 575 | //make sure it's the correct one |
| 576 | if (!$(e.target).is(el)) { return; } |
| 577 | // remove the callback |
| 578 | el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); |
| 579 | updateAfterSlideTransition(); |
| 580 | }); |
| 581 | } else { //duration = 0 |
| 582 | updateAfterSlideTransition(); |
| 583 | } |
| 584 | } else if (type === 'reset') { |
| 585 | el.css(slider.animProp, propValue); |
| 586 | } else if (type === 'ticker') { |
| 587 | // make the transition use 'linear' |
| 588 | el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear'); |
| 589 | el.css(slider.animProp, propValue); |
| 590 | if (duration !== 0) { |
| 591 | el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { |
| 592 | //make sure it's the correct one |
| 593 | if (!$(e.target).is(el)) { return; } |
| 594 | // remove the callback |
| 595 | el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); |
| 596 | // reset the position |
| 597 | setPositionProperty(params.resetValue, 'reset', 0); |
| 598 | // start the loop again |
| 599 | tickerLoop(); |
| 600 | }); |
| 601 | } else { //duration = 0 |
| 602 | setPositionProperty(params.resetValue, 'reset', 0); |
| 603 | tickerLoop(); |
| 604 | } |
| 605 | } |
| 606 | // use JS animate |
| 607 | } else { |
| 608 | animateObj = {}; |
| 609 | animateObj[slider.animProp] = value; |
| 610 | if (type === 'slide') { |
| 611 | el.animate(animateObj, duration, slider.settings.easing, function() { |
| 612 | updateAfterSlideTransition(); |
| 613 | }); |
| 614 | } else if (type === 'reset') { |
| 615 | el.css(slider.animProp, value); |
| 616 | } else if (type === 'ticker') { |
| 617 | el.animate(animateObj, duration, 'linear', function() { |
| 618 | setPositionProperty(params.resetValue, 'reset', 0); |
no test coverage detected