From Design pattern
Jump to: navigation, search
Line 30: Line 30:
 
}
 
}
  
 +
});
 +
 +
 +
 +
$('elements').onScreen({
 +
  container: window,
 +
  direction: 'vertical',
 +
  doIn: function() {
 +
    // Do something to the matched elements as they come in
 +
  },
 +
  doOut: function() {
 +
    // Do something to the matched elements as they get off scren
 +
  },
 +
  tolerance: 0,
 +
  throttle: 50,
 +
  toggleClass: 'onScreen',
 +
  lazyAttr: null,
 +
  lazyPlaceholder: 'someImage.jpg',
 +
  debug: false
 
});
 
});

Revision as of 18:01, 30 May 2014

$("#mw-content-text h3").each(function(){

$(this).wrap("<div class=example></div>");
var ex_div=$(this).closest("DIV");
//ex_div.css("border","1px solid red");
//console.log(ex_div);
while(ex_div.next().length && !ex_div.next().prop("tagName").match(/h3|h2|div/i)){
	nextobj=ex_div.next();
	//console.log(nextobj.prop("tagName"));
ex_div.append(nextobj);
}

});

$("div.example").each(function(){

var video=$("iframe,object",this);
if(video.length){
	//console.log(video.eq(0),video.eq(0).prop("clientWidth"));
if(video.eq(0).prop("clientWidth")<=300){
	video.insertAfter($("h3",this));
	$(this).css("width",300).css("float","left").css("margin","0 30px 0 0");

	//console.log($(this).next().prop("className"));
	if($(this).next().prop("className")!="example") $(this).after("<br clear=both>");
}else {
$(this).before("<br clear=both>");

}
}

});



$('elements').onScreen({
   container: window,
   direction: 'vertical',
   doIn: function() {
     // Do something to the matched elements as they come in
   },
   doOut: function() {
     // Do something to the matched elements as they get off scren
   },
   tolerance: 0,
   throttle: 50,
   toggleClass: 'onScreen',
   lazyAttr: null,
   lazyPlaceholder: 'someImage.jpg',
   debug: false
});