Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9111173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:26:34+00:00 2026-06-17T03:26:34+00:00

I have a website that I have added some basic Mootools animation to. Here

  • 0

I have a website that I have added some basic Mootools animation to. Here is the page of the website i have a question on:

http://www.humsdrums.com/portfolio/webdesign.html

You will notice that when you mouse over the large images, they fade and a magnifying glass tweens down. Here is the Mootools class called “Magnify” I made for this:

var Magnify = new Class({

Implements : [Options, Events],


options : {

    },

initialize : function (item, image, options)
{
    this.setOptions(options);
    this.div = document.id(item);
    this.img = $$(image);

    this.tweenBackground = new Fx.Tween(this.div,{
        duration:'250',
        property:'background-position'

    });

    this.div.addEvent('mouseenter', this.reveal.bind(this));

    this.div.addEvent('mouseleave', this.hide.bind(this));

},

reveal : function()
{
    this.tweenBackground.cancel();
    this.tweenBackground.start('175px -78px', '175px 90px');
    this.img.tween('opacity', .15);
    console.log('mouse over');


},

hide :function ()
{
    this.tweenBackground.cancel();
    this.tweenBackground.start('175px 90px', '175px -78px');
    this.img.tween('opacity', 1);


}

});

I then need to initialize an instance of the class for each element i want to do this by grabbing the css id.

window.addEvent('domready', function()
{

var magnify1 = new Magnify('p1', '#p1 img');
var magnify2 = new Magnify('p2', '#p2 img');
var magnify3 = new Magnify('p3', '#p3 img');
var magnify4 = new Magnify('p4', '#p4 img');
});

What I want to be able to do is simple give each element I want to have this functionality a CSS class of “magnify so I don’t have to use individual ID’s and add another instance of the Mootools class every time.

If I the element a CSS class and put it into my Mootools class, it breaks. Even if it didn’t break, it seems like Mootools would simply make all elements with that CSS class animate at the same time when only one is moused over.

How would I detect which instance of the “magnify CSS class is being moused over? My only thoughts were to find a way to grab all the elements with the “magnify” CSS class, put them into an array and then check to see if the item being hovered over equals one of the items in the array. I don’t know how to do that or if that is the best way.

Any help or suggestions would be great! Let me know if you want to see more code or if I can explain something better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:26:35+00:00Added an answer on June 17, 2026 at 3:26 am

    you need to code to patterns more. first of all – you have a relationship of 2 elements – a containing div and an image.

    your event is actually on the parent el but you also need to reference and animate the inner element (the image).

    your selector is simply div.item-port > img if you want to grab all images. div.item-port > img ! div.item-port will grab the parent divs instead of those that have an image as direct child only. etc.

    then you need to decide what element to attach the event to. you have many choices in your markup.

    before you even get there, you have a a href which wraps BOTH your elements. that allows you to use a cross-browser :hover pseudo.

    you can very easily do in pure css:

    div.port-item {
        /* defaults you already have and then ... */
        background-position: 175px -78px;
        -webkit-transition: all 0.2s ease-out 0s;
        -moz-transition: all 0.2s ease-out 0s;
        -ms-transition: all 0.2s ease-out 0s;
        -o-transition: all 0.2s ease-out 0s;
        transition: all 0.2s ease-out 0s;
    }
    
    .portfolio-item a:hover div.port-item {
        background-position: 175px 90px;
    }
    
    .portfolio-item a:hover img {
        opacity: .15; // etc for cross-browser
    }
    

    only if you want to recover when the browser does not support transitions, you should instantiate your js class. http://jsfiddle.net/wMnzb/4/

    var Magnify = new Class({
    
      Implements: [Options],
    
      options: {
        parent: 'div'
      },
    
      initialize: function (images, options) {
        this.setOptions(options);
        this.elements = document.getElements(images);
        this.attachEvents();
      },
      attachEvents: function () {
        var selector = this.options.parent;
        this.elements.each(function (el) {
          var parent = el.getParent(selector);
    
          parent.set('tween', {
            duration: '250',
            link: 'cancel'
          });
          parent.addEvents({
            mouseenter: function () {
              this.tween('background-position', '175px 90px');
              el.fade(0.15);
            },
            mouseleave: function () {
              this.tween('background-position', '175px -78px');
              el.fade(1);
            }
          });
        });
      }   
    
    });
    
    new Magnify('div.port-item > img');
    

    simplified as much as is feasible, but you get the idea – completely ambiguous from ids and any such repetitive specificity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small issue with some .htaccess rules on our website - http://www.presencemultimedia.co.uk
I have a website that started with ASP.NET and over time has had some
This morning I noticed that some results to our website have been poisoned in
I have website http://yournextleap.com/fresher-jobs Please find out last div having HTML <div data-recommendation= data-id=3790
I have an asp.net website which contains a Thread that fetches some data from
I downloaded a jQuery slider from http://basic-slider.com/ and I've put it onto my website.
I need to automate some tasks on a website that does not have an
So basically I have website that has names of cities that can be checked
I have a website that is mainly based on JavaScript. It uses a REST
I have a website that is mirrored cross two sub-domains. So I have separate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.