Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Hoochie Coochie Man on May 10, 2008, 11:46:50 AM

Title: Mousewheel for Resize Image
Post by: Hoochie Coochie Man on May 10, 2008, 11:46:50 AM
Mousewheel for Resize Image (a little tip)

Demo (http://demos111.mootools.net/MousewheelCustom)

In Subs.php
Find:
'content' => '<img src="$1" alt="" border="0" />',

Change:
'content' => '<img id="hcm1" src="$1" alt="" border="0" />',

In index.tempalte.php
Find:
</head>

<script language="JavaScript" type="text/javascript" src="', $settings['theme_url'], '/mootools.js"></script>

<script type="text/javascript">
window.addEvent("domready", function(){
Element.Events.extend({
"wheelup": {
type: Element.Events.mousewheel.type,
map: function(event){
event = new Event(event);
if (event.wheel >= 0) this.fireEvent("wheelup", event)
}
},

"wheeldown": {
type: Element.Events.mousewheel.type,
map: function(event){
event = new Event(event);
if (event.wheel <= 0) this.fireEvent("wheeldown", event)
}
}
});

/* Mousewheel by Hoochie Coochie Man */
$("hcm1").addEvents({
"wheelup": function(e) {
e = new Event(e).stop();

this.width *= 1.1;
this.height *= 1.1;
},

"wheeldown": function(e) {
e = new Event(e).stop();

if (this.width-30 >= 30) {
this.width /= 1.1;
this.height /= 1.1;
}
}
});

});
</script>


And finaly put the attached .js file to your theme file.
Title: Re: Mousewheel for Resize Image
Post by: L.G.S on May 11, 2008, 10:21:19 AM
Looks good. Quite a bit of code though, will it slow down pages with quite a few images?
Title: Re: Mousewheel for Resize Image
Post by: H on May 11, 2008, 10:24:51 AM
/me moves to Tips and Tricks :)

mootools is AFAIK a whole framework. Perhaps the needed function(s) could be separated?
Title: Re: Mousewheel for Resize Image
Post by: Shark-Time on December 12, 2008, 05:55:04 AM
haha nice trick yr...
Title: Re: Mousewheel for Resize Image
Post by: enjoy1985 on January 20, 2009, 10:03:58 PM
nice.  :D
Title: Re: Mousewheel for Resize Image
Post by: FlixyaFriend on January 30, 2009, 06:08:57 AM
nice Tips and Tricks  :)
Thank