Help migrating Script to mootools 1.2

a place to get help

Moderator: 1.2 Moderators

Forum rules
  • Every time you need help create a new thread (but please use the search function before, as your problem maybe has already been solved)
  • use code highlighting (help)
  • After your problem has been solved you have to rename the subject to "[solved] <Topicname>" AND set the Topic icon as solved (the green check)

Help migrating Script to mootools 1.2

Postby elpaisa on Sun Mar 07, 2010 4:35 am

Hi!

first, this is my first post in this forum, and i am very new to mootools, i have understood a little how it works, but this is not my strong, however i need help with a bit o code of a scroller that is for mootools 1.1, i need to upgrade it to 1.2, thanks for your help!.

  1.      <script type="text/javascript">
  2.      window.addEvent('load', function(){
  3.       var totIncrement      = 0;
  4.       var increment         = 190;
  5.       var maxRightIncrement = increment*(-6);
  6.       var fx = new Fx.Tween('scroller', 'margin-left', {
  7.                 duration: 1000,
  8.                 transition: Fx.Transitions.Back.easeInOut,
  9.                 wait: true
  10.        });
  11.        
  12.       $('previous').addEvents({
  13.           'click' : function(event){
  14.           if(totIncrement<0){
  15.                     totIncrement = totIncrement+increment;
  16.                     fx.cancel()
  17.                     fx.set(totIncrement);
  18.                 }
  19.             }                
  20.       });
  21.       $('next').addEvents({
  22.           'click' : function(event){
  23.              if(totIncrement>maxRightIncrement){
  24.                  totIncrement = totIncrement-increment;
  25.                 fx.cancel()
  26.                 fx.set(totIncrement);
  27.             }
  28.           }              
  29.       })
  30. });
  31.     </script>
  32.  
Life is too short to live it in the mediocrity "Abraham Lincoln"..
GRAPHICS INC.
International Media Arts.

http://www.graphicsinc.us
elpaisa
 
Posts: 3
Joined: Sun Mar 07, 2010 4:06 am
Location: Colombia - USA

Re: Help migrating Script to mootools 1.2

Postby wowenkho on Sun Mar 07, 2010 6:11 am

the only problem i see is that in Fx.Tween in 1,2, there are only 2 arguments asked. you don't place the property as the 2nd argument anymore. and the 3rd argument, the option object, becomes the 2nd argument. the property becomes part of the object as the "property" option. add to that, the "wait" option is now replaced by the "link" option. for more info, check the documentation out. http://mootools.net/docs/core/Fx/Fx.Tween
  1. var fx = new Fx.Tween('scroller', {
  2.   property: 'margin-left', //property is now an option
  3.   duration: 1000,
  4.   transition: 'back:in:out', //changed this to the shorthand
  5.   link: 'ignore'
  6. });
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: Help migrating Script to mootools 1.2

Postby elpaisa on Sun Mar 07, 2010 5:04 pm

Hi body, thanks for your reply, i've changed the code, and it works almost fine, i mean it scrolls but doesn't apply the smooth transition, by the rest is good, i only had to change all the stop for cancel, and start for set, to make it work, but still no transition.

thans again!.
Life is too short to live it in the mediocrity "Abraham Lincoln"..
GRAPHICS INC.
International Media Arts.

http://www.graphicsinc.us
elpaisa
 
Posts: 3
Joined: Sun Mar 07, 2010 4:06 am
Location: Colombia - USA

Re: Help migrating Script to mootools 1.2

Postby wowenkho on Mon Mar 08, 2010 3:35 am

could you paste how your code currently looks like with the recent fixes you've made?
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: Help migrating Script to mootools 1.2

Postby elpaisa on Wed Mar 10, 2010 1:54 am

this is my new code:

  1.      window.addEvent('load', function(){
  2.       var totIncrement      = 0;
  3.       var increment         = 100;
  4.       var maxRightIncrement = increment*(-6);
  5.  
  6.      var fx = new Fx.Tween('scroller', {
  7.         property: 'margin-left', //property is now an option
  8.         duration: 1000,
  9.         transition: Fx.Transitions.Bounce.easeOut, //changed this to the shorthand
  10.         link: 'ignore'
  11.       });
  12.        
  13.       $('previous').addEvents({
  14.           'click' : function(event){
  15.           if(totIncrement<0){
  16.                     totIncrement = totIncrement+increment;
  17.                     fx.cancel()
  18.                     fx.set(totIncrement);
  19.                 }
  20.             }                
  21.       });
  22.       $('next').addEvents({
  23.           'click' : function(event){
  24.              if(totIncrement>maxRightIncrement){
  25.                  totIncrement = totIncrement-increment;
  26.                 fx.cancel()
  27.                 fx.set(totIncrement);
  28.             }
  29.           }              
  30.       })
  31. });
  32.  
Life is too short to live it in the mediocrity "Abraham Lincoln"..
GRAPHICS INC.
International Media Arts.

http://www.graphicsinc.us
elpaisa
 
Posts: 3
Joined: Sun Mar 07, 2010 4:06 am
Location: Colombia - USA


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests