Jump to content

stoping a appendto from happening


Shadowing

Recommended Posts

Hey guys I"m trying to edit someones plug in and im having a problemI need to prevent the appendTo from happening more then once what this plug in does is it has a div follow your mouse cursorbut the problem i have with it is if i move the mouse to fast to the right it was making the div be removed so i exit out the remove "preview" but now i cant prevent it from conintuing apending the id previewone thing that did work was using $('#preview').html(''); before it so it clears it first but it caused lag to happend.

(function($) {    $.fn.trackStar = function(options) {	    debug(this);	    var opts = $.extend({}, $.fn.trackStar.defaults, options);	    return this.each(function() {		    $this = $(this);		    var o = $.meta ? $.extend({}, opts, $this.data()) : opts;		     		    $this.hover(function(event) {			    $('body').append('<div id="preview" style="z-index:800; position: absolute;"></div>');			   			  			     $('#' + opts.displayID).clone().css('id', '').appendTo($('#preview')).show(0);			     			    }		   		    $('#preview')				    .css('top', (event.pageY - opts.xOffset) + 'px')				    .css('left', (event.pageX + opts.yOffset) + 'px')				    .fadeIn('fast');	    }, function(event) {		    //$('#preview').remove();	    });	    $this.mousemove(function(event) {		    $('#preview')				    .css('top', (event.pageY - opts.xOffset) + 'px')				    .css('left', (event.pageX + opts.yOffset) + 'px');	    });	    });    };    function debug($obj) {	    if (window.console && window.console.log) {			 ;//console.log();	    }    };    // plug-in defaults    $.fn.trackStar.defaults = {	    xOffset: 10,	    yOffset: 30    };})(jQuery);

Link to comment
Share on other sites

nice ya that worked. It made it alot smoother now but damn there is still lag. The problem happends when i move the mouse to the right really fast the mouse catches up to the picture that is following the mouse. But I believe the problem is cause the mouse is leaving the area when it hovers on top of the picture following the mouse so I need to figure out how to make it ignore it when it hovers on top of the picture

Edited by Shadowing
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...