I'm not sure what you mean. There are no transitions. In jQuery the easing is the mathematical algorithm applied to a transition like fading or sliding. The default is what they call 'swing' (I think it's faster at the beginning and slows as the target state is neared, but I'm not sure, I just know it's nonlinear). I think the only other choice is 'linear' (the effect is applied to an equal degree during the entire time of transition). There are more of them available with the jQuery UI unit and/or other code written for jQuery that provide other optional easings. But jQuery itself has just the two.
What you probably mean is how to have a jQuery transition instead of just switching from one RSS feed item to the next by injecting in turn each formatted feed item into the feed container via its innerHTML property.
I played around with that idea over the weekend. To accommodate adding any code (jQuery or otherwise) for transitions, I added a beforeitem function and an optional boolean I called noautoload (which if set to true stops the injection of the formatted feed item as the feed container's innerHTML). I also arranged for both the new beforeitem and the onitemload functions to receive the formatted item as their sole parameter so it can potentially be used in other ways and/or at other times than the ticker script ordinarily would do.
Here's the modified ticker script:
gajaxticker.js
Here's how I utilized it to add optional jQuery transitions (notice the 2 highlighted configuration lines):
Code:
<script type="text/javascript">
var socialfeed=new gfeedrssticker("example2", "example2class", 6000, "_new")
socialfeed.addFeed("Slashdot", "http://feeds.feedburner.com/tar-home?format=xml") //Specify "label" plus URL to RSS feed
//Specify "label" plus URL to RSS feed
socialfeed.displayoptions("label datetime snippet") //show the specified additional fields
socialfeed.setentrycontainer("li") //Display each entry as a DIV
socialfeed.filterfeed(20, "label") //Show 15 entries, sort by label
socialfeed.entries_per_page(1)
socialfeed.noautoload = true;
socialfeed.beforeitem = function(item){
var transition = 'slideUp'; // 'hide', 'show', 'fadeOut', 'slideUp', or 'slideDown'
var duration = 900; // duration of the transition effect 'slow', 'normal', 'fast' or unquoted milliseconds
var $ = jQuery, $fc = $(this.feedcontainer), $fimg = $(this.feeds[this.messagepointer].content).find('img').eq(0), $title, mw, $p, $r, $fcc,
where = /hide|Out|Up/.test(transition)? 'prepend' : 'append', which = where === 'append'? 'last' : 'first', transitfunc;
if(!this.wrapped){
this.loadingwrap = $('<div style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;"></div>').append($fc.children()).appendTo($fc);
$fc.css({position: 'relative', overflow: 'hidden'});
this.wrapped = true;
}
if(!this.loadingwrap || this.feeds.length === $fc.children().length - 1){
if(this.loadingwrap.length){this.loadingwrap.remove(); this.loadingwrap = 0;}
if(where === 'append'){$fc.children().first().hide().appendTo($fc)[transition](duration);}
else{$fc.children().last().show().prependTo($fc).next()[transition](duration);}
} else {
$fc[where]('<div style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;">' + item + '</div>');
$title = $fc.find('.titlefield')[which](); mw = $fc.children().innerWidth() - 5;
$p = $fimg.css({maxWidth: mw, height: 'auto', maxHeight: 210, width: 'auto'});
$r = $p.parent('a').length? $p.parent('a') : $p;
if($r.length){$title.before($('<div class="feedimage"></div>').append($r));}
$fcc = where === 'append'? $fc.children().last().css({visibility: 'hidden'}) : $fc.children().eq(1);
transitfunc = where === 'append'? function(){$fcc.css({visibility: ''}).hide()[transition](duration);} : function(){$fcc[transition](duration);};
if($fimg.length){
$(new Image()).bind('load error', function(){
transitfunc();
}).attr('src', $fimg.attr('src'));
} else {
transitfunc();
}
}
};
socialfeed.init() //Always call this last
</script>
Here are the styles I used with the above:
Code:
#example2{ /*Demo 2 main container*/
width: 600px;
height: 290px;
border: 1px dashed black;
padding: 4px;
background-color: #EEEEEE;
}
#example2 > div {
margin: 4px;
background-color: #EEEEEE;
}
#example2 ul{ /*Demo 2 UL container*/
margin: 0;
padding-left: 18px;
}
#example2 ul li{ /*Demo 2 LI that surrounds each entry*/
margin-bottom: 4px;
}
I elected to go with the snippet, but if you're using the description the container (#example2) will probably have to be taller, and you will need the image hiding css from before:
Code:
#example2 img {
display: none;
}
#example2 .feedimage img {
display: block;
}
Bookmarks