Results 1 to 5 of 5

Thread: Looking for a script like this :ahover animation

  1. #1
    Join Date
    Nov 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Looking for a script like this :ahover animation

    Hey guys I've always wanted to do something like this but I never thought it was possible with CSS or whatever it is.
    I've been tried to work this thing out but I can't figure out how to make it work.

    Basically here is what I'm looking for:

    https://www.google.com/chrome/browse...l?platform=win

    Have u guys did mouseover on the top left logo?

    Any hint on getting that effect??

    Thanks in advance.

  2. #2
    Join Date
    Aug 2009
    Location
    utf-8
    Posts
    205
    Thanks
    4
    Thanked 7 Times in 7 Posts

    Default

    Look into css masking. This is the code that they used for the mouseover effect

    Code:
    -webkit-mask: -webkit-gradient(radial, 17 17, 123, 17 17, 138, from(rgb(0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.2)), to(rgb(0, 0, 0)));
    An inline div is a freak of the web and should be beaten until it becomes a span

  3. #3
    Join Date
    Nov 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah I know I've found that but the CSS is totally a mess and it also need JavaScript.

    I've tried to make the page again using everything that is on that page but when I try to detele menu or some div it doesn't work anymore..it's like it is connected to other calls.

    CSS: http://www.google.com/intl/it_ALL/chrome/assets/common/css/chrome.min.css
    JavaScript: http://www.google.com/chrome/assets/common/js/chrome-installer.min.js

  4. #4
    Join Date
    Nov 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've found it...but it also gives the effect with u leave with the mouse -.-

    http://www.script-tutorials.com/webkit-image-effects-with-masks/

    How can I fix this?

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's actually pretty simple. In that version of jQuery (and I think all, but this may have changed) the .hover() function allows one to pair at least two functions. It's the equivalent of mouseneter combined with mouseleave. But they only specified one function. In that case, it gets repeat for mouseleave. So, you can either add an empty function at the end, or some other function if you want something else to happen on mouseleave, or just change hover to mouseenter (probably the simplest):

    Code:
    jQuery(document).ready(function($){
     
        $('#examples img').mouseenter(function () {
            var $imgObj = $(this);
     
            // class name
            var sClass = $(this).attr('class');
     
            // radius
            var iRad = 0;
     
            // interval
            var iInt;
            if (iInt) window.clearInterval(iInt);
     
            // loop until end
            iInt = window.setInterval(function() {
                var iWidth = $imgObj.width();
                var iHalfWidth = iWidth / 2;
                var iHalfHeight = $imgObj.height() / 2;
     
                if (sClass == 'type1') {
                    $imgObj.css('-webkit-mask', '-webkit-gradient(radial, '+iHalfWidth+' '+iHalfHeight+', '+ iRad +', '+iHalfWidth+' '+iHalfHeight+', '+ (iRad + 30) +', from(rgb(0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.2)), to(rgb(0, 0, 0)))');
                } else if (sClass == 'type2') {
                    $imgObj.css('-webkit-mask', '-webkit-gradient(radial, '+iHalfHeight+' '+iHalfHeight+', '+ iRad +', '+iHalfHeight+' '+iHalfHeight+', '+ (iRad + 30) +', from(rgb(0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.2)), to(rgb(0, 0, 0)))');
                }
     
                // when radius is more than our width - stop loop
                if (iRad > iWidth) {
                    window.clearInterval(iInt);
                }
     
                iRad+=2;
            }, 10);
        });
    });
    Alternate method (adding a dummy function at the end - scroll down to see it - as I say you can add stuff in there if you want, but empty is what stops the effect from repeating):

    Code:
    jQuery(document).ready(function($){
     
        $('#examples img').hover(function () {
            var $imgObj = $(this);
     
            // class name
            var sClass = $(this).attr('class');
     
            // radius
            var iRad = 0;
     
            // interval
            var iInt;
            if (iInt) window.clearInterval(iInt);
     
            // loop until end
            iInt = window.setInterval(function() {
                var iWidth = $imgObj.width();
                var iHalfWidth = iWidth / 2;
                var iHalfHeight = $imgObj.height() / 2;
     
                if (sClass == 'type1') {
                    $imgObj.css('-webkit-mask', '-webkit-gradient(radial, '+iHalfWidth+' '+iHalfHeight+', '+ iRad +', '+iHalfWidth+' '+iHalfHeight+', '+ (iRad + 30) +', from(rgb(0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.2)), to(rgb(0, 0, 0)))');
                } else if (sClass == 'type2') {
                    $imgObj.css('-webkit-mask', '-webkit-gradient(radial, '+iHalfHeight+' '+iHalfHeight+', '+ iRad +', '+iHalfHeight+' '+iHalfHeight+', '+ (iRad + 30) +', from(rgb(0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.2)), to(rgb(0, 0, 0)))');
                }
     
                // when radius is more than our width - stop loop
                if (iRad > iWidth) {
                    window.clearInterval(iInt);
                }
     
                iRad+=2;
            }, 10);
        }, function(){});
    });
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Customizeable animation script tutorial
    By aqeel in forum Other
    Replies: 0
    Last Post: 09-05-2011, 09:45 AM
  2. Resolved Animation with JQuery Treeview script
    By moswell in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-12-2009, 07:19 PM
  3. Accordion Script - turning off animation?
    By Toccamonium in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 06-04-2008, 01:32 PM
  4. Replies: 4
    Last Post: 12-17-2005, 04:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •