Closed elinfante closed 9 years ago
Are you using a TransitionableTransform? Please post the code from your controller or directive.
I am actually using Transitionable for the rotation. There you go the directive:
.directive('bzCarrouselThumb', ['$famous','$timeout', function($famous,$timeout) {
return {
restrict: 'A',
scope: false,
link: function(scope,el,attr) {
var EventHandler = $famous['famous/core/EventHandler'];
var Transform = $famous["famous/core/Transform"];
var Transitionable = $famous["famous/transitions/Transitionable"];
var SnapTransition = $famous["famous/transitions/SnapTransition"];
var width = 200;
var height = 200;
var offset = 30;
var delay = 300;
var initAnim = Transform.translate(translateThumbX(scope.$index), translateThumbY(scope.$index) +300, 0)
var animIn = Transform.translate(translateThumbX(scope.$index), translateThumbY(scope.$index), 0)
var transform = new Transitionable(initAnim);
var rotY = new Transitionable(0);
scope.carrouselEvent = new EventHandler();
scope.pipe.subscribe(scope.carrouselEvent);
function translateThumbX(index) {
return 1920 - ( (width + 35) * (index) + (width/2+offset));
}
function translateThumbY(index) {
return 800;
}
function enter() {
transform.delay(delay * scope.$index);
return transform.set(animIn, {duration: 300}, onEnterEnd)
};
function onEnterEnd() {
if (scope.$index == scope.photos.length - 1) {
scope.carrouselEvent.emit('carrousel:allThumbsIn');
}
}
function leave() {
var leaveItem = new Transform.translate(translateThumbX(scope.$index) + 200 + offset, translateThumbY(scope.$index), 0)
return transform.set(leaveItem, {duration: 250,transition: SnapTransition}, onLeaveEnd)
};
function onLeaveEnd() {
el.remove();
}
function halt() {
scope.transform.halt()
};
function rotate() {
console.log("rotate");
rotY.set(Math.PI / 4, {duration:500});
}
function reposition() {
var slide = new Transform.translate(translateThumbX(scope.$index), translateThumbY(scope.$index), 0)
transform.delay(50 * scope.$index);
return transform.set(slide, {duration: 250,transition: SnapTransition})
}
// When I remove one of the photos from the array I trigger this
scope.$watch('photos', function(newV,oldV){
if (newV.length != oldV.length) {
reposition();
}
},true);
// ================================================================================
angular.extend(scope, {
width: width,
height: height,
enter: enter,
leave: leave,
halt: halt,
transform: transform,
rotate:rotate,
rotY: rotY,
});
//Apply changes that could be made to animations that are binding
$timeout(function() {
scope.$apply();
});
}
};
}]);
You should try using TransitionableTransform instead of a Transitionable.
Hi @elinfante
Is this still an issue or did @steveblue solution work?
Thanks,
Jordan
I am going to close this. Please reopen it if it is still an issue. Thanks - Jordan
I have created a carrousel and when I click on each thumb It should rotate from the center. I got that bit working fine but for some reason the perspective is wrong, is not head on therefore they all look different when they should be the same.
I am a bit confused why is doing that, any ideas?
This is the directive:
Attached there is a picture of what the problem is:
Thanks