JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 20th, 2012, 07:28 PM
man_redeemed man_redeemed is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 man_redeemed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 2 sec
Reputation Power: 0
How to use clearInterval() to remove function from selected element

hi! I'm not a progammer though I can read written code and understand it. I found a couple of scripts and manipulated them to accomplish what I want but am at a loss to finish my effect and need help.

my inspiration comes from the WM Mango phone OS where unselected menu buttons will resize and undulate when you select a button to move. on my site I've created an undulating menu of blocks that individually expand in size when moused-over.

the problem is both functions to resize the blocks and make them undulate manipulate the CSS variables "top" and "left" so if you resize a block while it is undulating, the resize effect looks very weird (because the constant position updating conflicts with each other). I have managed to successfully stop the undulate function on :HOVER by including
Code:
clearInterval(xxx);
in the expand function but the problem is all the blocks stop undulating.

I need to stop the undulating function for the block that :HOVER is applied and then restart undulating when the mouse is removed but AFTER the .animate() has finished for the resize back to normal.

I don't know if I can add something to my existing code or if I need to completely rewrite to make it work. I do plan on rewriting the code to reduce the size of the undulating function.

Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function() {

  $(".div1").hover(
    function() {
	clearInterval(elled);
      $(this).animate({
	  opacity: "1",
        height: "+=90",
		width: "+=90",
		top: "-=45",
		left: "-=45" //adds 250px
        }, 'slow' //sets animation speed to slow
      );
	  this.style.zIndex = 50;

    },
    //on mouseout
    function() {
      $(this).animate({
	  opacity: ".5",
        height: "-=90px",
		width: "-=90px",
		top: "+=45",
		left: "+=45"
        }, 'slow'
      );
	  this.style.zIndex = 10;
    }
  );

});
</script> 

<style type="text/css">
.div1{
	position:absolute;
    height:80px;
	width:80px;
	opacity:.5;
	filter:alpha(opacity=50);
	z-index:1;
    overflow:hidden;
    background: red; /* just for demo */
	margin: 0 auto;
}
</style>

<body>
<div class="1 div1" id="test">This is div 1</div>
<div class="2 div1" id="test2">This is div 2</div>
<div class="3 div1" id="test3">This is div 3</div>
<div class="4 div1" id="test4">This is div 4</div>
<div class="5 div1" id="test5">This is div 5</div>
<div class="6 div1" id="test6">This is div 6</div>
<div class="7 div1" id="test7">This is div 7</div>
<div class="8 div1" id="test8">This is div 8</div>
<script>
var banner = document.getElementById("test");
var banner2 = document.getElementById("test2");
var banner3 = document.getElementById("test3");
var banner4 = document.getElementById("test4");
var banner5 = document.getElementById("test5");
var banner6 = document.getElementById("test6");
var banner7 = document.getElementById("test7");
var banner8 = document.getElementById("test8");
    start = 0;
	again = 0;
function sine(){
  banner.style.top = 10 * Math.sin( start ) + 80 + 'px';
  banner.style.left = 3 * Math.sin( again ) + 80 + 'px';
  banner2.style.top = 10 * Math.sin( start - 1 ) + 80 + 'px';
  banner2.style.left = 3 * Math.sin( again - 1 ) + 170 + 'px';
  banner3.style.top = 7 * Math.sin( start + .5 ) + 170 + 'px';
  banner3.style.left = 2 * Math.sin( again ) + 80 + 'px';
  banner4.style.top = 7 * Math.sin( start - 1.5 ) + 170 + 'px';
  banner4.style.left = 2 * Math.sin( again - 1 ) + 170 + 'px';
  banner5.style.top = 4 * Math.sin( start + .75) + 260 + 'px';
  banner5.style.left = 3 * Math.sin( again ) + 80 + 'px';
  banner6.style.top = 4 * Math.sin( start - 1.75 ) + 260 + 'px';
  banner6.style.left = 3 * Math.sin( again - 1 ) + 170 + 'px';
  banner7.style.top = 2 * Math.sin( start + .5 ) + 350 + 'px';
  banner7.style.left = 3 * Math.sin( again ) + 80 + 'px';
  banner8.style.top = 2 * Math.sin( start - 1.5 ) + 350 + 'px';
  banner8.style.left = 3 * Math.sin( again - 1 ) + 170 + 'px';
  start += 0.05;
  again += .1;
}
var elled = window.setInterval( sine, 1000/26 );
</script>
</body>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > How to use clearInterval() to remove function from selected element

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap