<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Farblondzshet in Code &#187; JQuery</title>
	<atom:link href="http://matthewmanela.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://matthewmanela.com</link>
	<description>The life and work of Matthew Manela</description>
	<lastBuildDate>Wed, 01 Sep 2010 21:54:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Synchronizing Scrollbars using JQuery</title>
		<link>http://matthewmanela.com/2009/03/19/synchronizing-scrollbars-using-jquery/</link>
		<comments>http://matthewmanela.com/2009/03/19/synchronizing-scrollbars-using-jquery/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 23:29:11 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blogs.msdn.com/matt/archive/2009/03/19/synchronizing-scrollbars-using-jquery.aspx</guid>
		<description><![CDATA[I just wrote this simple plugin for JQuery which lets you synchronize the scroll bars of any collection of elements.&#160; This lets you move the scrollbar of one div it have the scrollbars’ of the rest of the divs move the same exact amount.  Here i... <a href="http://matthewmanela.com/2009/03/19/synchronizing-scrollbars-using-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just wrote this simple plugin for <a href="http://jquery.com/">JQuery</a> which lets you synchronize the scroll bars of any collection of elements.  This lets you move the scrollbar of one div it have the scrollbars’ of the rest of the divs move the same exact amount.</p>

<p>Here is the code:</p>

<pre class="brush:js">
jQuery.fn.synchronizeScroll = function() {
    var elements = this;
    if (elements.length <= 1) return;

    elements.scroll(
    function() {
        var left = $(this).scrollLeft();
        var top = $(this).scrollTop();
        elements.each(
        function() {
            if ($(this).scrollLeft() != left) $(this).scrollLeft(left);
            if ($(this).scrollTop() != top) $(this).scrollTop(top);
        }
        );
    });
}
</pre>

<p>Using this is SUPER simple.  Lets say you have several divs defined as:</p>

<blockquote><p>&lt;div class=”scrollDiv” style=”overflow:auto;”&gt; .. some large content&lt;/div&gt;</p></blockquote>

<p>To synchronize the scrollbars’ on all divs with the class scrollDiv all you need to write is:</p>

<blockquote><p>$(“.scrollDiv”).synchronizeScroll();</p></blockquote>

<p><img src="http://blogs.msdn.com/aggbug.aspx?PostID=9491068" alt="" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2009/03/19/synchronizing-scrollbars-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated JQuery ResizeComplete method</title>
		<link>http://matthewmanela.com/2008/12/02/updated-jquery-resizecomplete-method/</link>
		<comments>http://matthewmanela.com/2008/12/02/updated-jquery-resizecomplete-method/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 22:59:20 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://matthewmanela.com/?p=240</guid>
		<description><![CDATA[HTML Source EditorWord wrap I made 2 slight changes and I think it works pretty well now.  I now detect if the browser is Firefox and use the regular resize event since its resize behaves like a resizeComplete.  I also &#8230; <a href="http://matthewmanela.com/2008/12/02/updated-jquery-resizecomplete-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>HTML Source EditorWord wrap</p>

<p>I made 2 slight changes and I think it works pretty well now.  I now detect if the browser is Firefox and use the regular resize event since its resize behaves like a resizeComplete.  I also modified the timeout a bit since I think 100 ms might be too small.</p>

<p>Here is the updated version:</p>

<pre class="brush:js">
jQuery.fn.resizeComplete = function(callback)
{

 var element = this;
 var height = element.height();
 var width = element.width();
 var monitoring = false;
 var timer;
 
 function monitorResizing()
 {
   monitoring = true;
   
   var newHeight = element.height();
   var newWidth = element.width();
   
   if(newHeight != height || newWidth != width)
   {
     height = newHeight;
     width = newWidth;
     timer = setTimeout(function() { monitorResizing() },200);
   }
   else
   {
     monitoring = false;
     clearTimeout(timer);
     callback();
   }
 }
 
 function onResize()
 {
   if(monitoring) return;
   monitorResizing();
 }
 
 if($.browser.mozilla)
 {
   element.resize(callback);
 }
 else
 {
   element.resize(onResize);
 }
 
 
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2008/12/02/updated-jquery-resizecomplete-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rough draft of a new JQuery method</title>
		<link>http://matthewmanela.com/2008/11/25/rough-draft-of-a-new-jquery-method/</link>
		<comments>http://matthewmanela.com/2008/11/25/rough-draft-of-a-new-jquery-method/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 20:00:07 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://matthewmanela.com/?p=243</guid>
		<description><![CDATA[I have run into issues recently with the browsers&#8217; implementation of the resize event on the window.  Opera, Safari, IE and Firefox all have different behaviors when this event is fired. Firefox only fires it when you release the mouse. &#8230; <a href="http://matthewmanela.com/2008/11/25/rough-draft-of-a-new-jquery-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have run into issues recently with the browsers&#8217; implementation of the resize event on the window.  Opera, Safari, IE and Firefox all have different behaviors when this event is fired.</p>

<ol>
    <li>Firefox only fires it when you release the mouse. </li>
    <li>IE fires this event many many times while resizing. </li>
    <li>Safari will fire continusouly while dragging</li>
    <li>Opera fires after the resizing stopped</li>
</ol>

<p>You can read more about this <a href="http://www.quirksmode.org/dom/events/resize.html" target="_blank">here</a>.</p>

<p>These differences led me to search for a solution.  I quickly wrote this proof of concept function today which may help solve this problem.  It is a JQuery add-on called resizeComplete.  It works by checking periodically after a resize starts and checks if the size of the object has changed.  Once no change is detected it invokes the call back method.</p>

<p>This has not been tested much at all but I think it might be on the right track.</p>

<pre class="brush:js">
jQuery.fn.resizeComplete = function(callback)
{
 
  var element = this;
  var height = element.height();
  var width = element.width();
  var monitoring = false;
  var timer;
  
  function monitorResizing()
  {
    monitoring = true;
    
    var newHeight = element.height();
    var newWidth = element.width();
    
    if(newHeight != height || newWidth != width)
    {
      height = newHeight;
      width = newWidth;
      timer = setTimeout(function() { monitorResizing() },100);
    }
    else
    {
      monitoring = false;
      clearTimeout(timer);
      callback();
    }
  }
  
  function onResize()
  {
    if(monitoring) return;
    monitorResizing();
  }
  
  element.resize(onResize);
  
}
</pre>

<p>Here is an example of its usage:</p>

<pre class="brush:js">
$(document).ready(function()
{
  $(window).resizeComplete(function(){ document.write('hi') });
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://matthewmanela.com/2008/11/25/rough-draft-of-a-new-jquery-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
