ABZiko
شنبه 29 شهریور 1393, 22:56 عصر
سلام، قصد دارم با پلاگین MagicScroll حالاتی رو شبیه پلاگین Superscrollorama درست کنم (هر دوتا شون ساخته یک نفرند)، ولی کار نمی کنه، می خوام وقتی رسیدم به قسمتی از صفحه یک عکسی جابه جا بشه و از یک مختصاتی بیاد به مختصات دیگه . کد های html :
<div id="description" style="margin-top:40px">
<div class="descriptionImage"><img src="HTML5.png" width="100%" height="100%" /></div>
<div class="descriptionText">
طراحی وب
</div>
</div>
اما از این به بعدش با کد ها js هستش (این کدها رو از صفحه خودش اونقدر کم کردم که رسیدم به این و قسمت مورد نظر خودم):
<script type="text/javascript">
var controller;
if (Modernizr.touch) {
var myScroll;
$(document).ready(function () {
// manual set hight (so height 100% is available within scroll container)
$(document).on("orientationchange", function () {
$(".description")
.css("min-height", $(window).height());
});
$(document).trigger("orientationchange"); // trigger to init
});
} else {
// init the controller
controller = new ScrollMagic({
globalSceneOptions: {
triggerHook: "onLeave"
}
});
}
</script>
<script type="text/javascript">
// animations
var nervousHat = new TimelineMax({repeat: -1, yoyo: true})
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "-=6", rotation: -3}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "-=10", left: "+=6", rotation: 0}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "+=6", rotation: 3}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "-=5", left: "-=3", rotation: 1.5}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "-=6", rotation: -1.5}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "+=3", rotation: 0}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "-=10"}));
var abracadabra = TweenMax.fromTo(".descriptionImage", 1, {top: -$(window).height()/3, left: 370, rotation: 20}, {top: 10, rotation: -20});
var reveal = new TimelineMax()
.add([
TweenMax.to(".description img", 1, {bottom: $(window).height(), left: "-=50", rotation: -20}),
TweenMax.from(".descriptionImage", 1, {scale: 0.4, top: "+=70", delay: 0.1}),
TweenMax.to(".descriptionImage", 0.8, {top: -$(window).height()/3, left: 450, rotation: 30}),
TweenMax.to(".descriptionImage", 1, {autoAlpha: 0})
]);
var laola = new TimelineMax()
.add(TweenMax.staggerTo(".description", 0.5, {top: -20}, 0.2))
.add(TweenMax.staggerTo(".description", 0.5, {top: 0}, 0.2), 0.5);
</script>
<script type="text/javascript">
var sceneOptions = {duration: 200, offset: -100};
var elements = $(".descriptionImage img");
// move
new ScrollScene(sceneOptions)
.addTo(controller)
.triggerHook("onCenter")
.triggerElement(elements)
.setTween(TweenMax.from(elements, 1, {left: "-50%", marginLeft: -200, ease: Back.easeOut}));
</script>
<div id="description" style="margin-top:40px">
<div class="descriptionImage"><img src="HTML5.png" width="100%" height="100%" /></div>
<div class="descriptionText">
طراحی وب
</div>
</div>
اما از این به بعدش با کد ها js هستش (این کدها رو از صفحه خودش اونقدر کم کردم که رسیدم به این و قسمت مورد نظر خودم):
<script type="text/javascript">
var controller;
if (Modernizr.touch) {
var myScroll;
$(document).ready(function () {
// manual set hight (so height 100% is available within scroll container)
$(document).on("orientationchange", function () {
$(".description")
.css("min-height", $(window).height());
});
$(document).trigger("orientationchange"); // trigger to init
});
} else {
// init the controller
controller = new ScrollMagic({
globalSceneOptions: {
triggerHook: "onLeave"
}
});
}
</script>
<script type="text/javascript">
// animations
var nervousHat = new TimelineMax({repeat: -1, yoyo: true})
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "-=6", rotation: -3}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "-=10", left: "+=6", rotation: 0}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "+=6", rotation: 3}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "-=5", left: "-=3", rotation: 1.5}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "-=6", rotation: -1.5}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "+=5", left: "+=3", rotation: 0}))
.add(TweenMax.to(".descriptionImage img", 0.3, {bottom: "-=10"}));
var abracadabra = TweenMax.fromTo(".descriptionImage", 1, {top: -$(window).height()/3, left: 370, rotation: 20}, {top: 10, rotation: -20});
var reveal = new TimelineMax()
.add([
TweenMax.to(".description img", 1, {bottom: $(window).height(), left: "-=50", rotation: -20}),
TweenMax.from(".descriptionImage", 1, {scale: 0.4, top: "+=70", delay: 0.1}),
TweenMax.to(".descriptionImage", 0.8, {top: -$(window).height()/3, left: 450, rotation: 30}),
TweenMax.to(".descriptionImage", 1, {autoAlpha: 0})
]);
var laola = new TimelineMax()
.add(TweenMax.staggerTo(".description", 0.5, {top: -20}, 0.2))
.add(TweenMax.staggerTo(".description", 0.5, {top: 0}, 0.2), 0.5);
</script>
<script type="text/javascript">
var sceneOptions = {duration: 200, offset: -100};
var elements = $(".descriptionImage img");
// move
new ScrollScene(sceneOptions)
.addTo(controller)
.triggerHook("onCenter")
.triggerElement(elements)
.setTween(TweenMax.from(elements, 1, {left: "-50%", marginLeft: -200, ease: Back.easeOut}));
</script>