Code Monkey home page Code Monkey logo

totem's Introduction

Totem Ticker jQuery Plugin

Totem is a jQuery plugin that turns lists into animated vertical tickers. It supports navigation and basic animation control.

Getting Started

A sample ticker might look something like this.

$('#vertical-ticker').totemticker({
row_height	:	'100px',
next		:	'#ticker-next',
previous	:	'#ticker-previous',
stop		:	'#stop',
start		:	'#start',
});

Options

The following options are available via the plugin array. Defaults are listed below.

next		:	null,		/* ID of next button or link */
previous	:	null,		/* ID of previous button or link */
stop		:	null,		/* ID of stop button or link */
start		:	null,		/* ID of start button or link */
row_height	:	'100px',	/* Height of each ticker row in PX. Should be uniform. */
speed		:	800,		/* Speed of transition animation in milliseconds */
interval	:	4000,		/* Time between change in milliseconds */
max_items	: 	null, 		/* Integer for how many items to display at once. Resizes height accordingly (OPTIONAL) */
stopmouse	:	false,		/* If set to true, the ticker will stop while mouse is hovered over it */

Contact

totem's People

Contributors

zachdunn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

totem's Issues

Freezes once, in Chrome, after first transition

Hi,

On first loading of a page containg a "totem" list, the list freezes after the first transition.

After any kind of interaction with the page or the "totem" list, the list functions as normal until the page is again loaded for the first time.

A page refresh will not replicate the issue. The page must be newly loaded.

Google Chrome Version: 11.0.696.77

Neil

Another IE 7 comma issue

Hi there,
first I'd like to thank you for this awesome script as it is exactly what was looking for for some time. The only issue I had with the demo (both online and the latest version downloaded from the github) is in IE7 where it apparently doesn't like the comma at the very last line of the options code...e.g. mousestop : true, makes the script not to work in IE7. By removing the comma everything is working fine then.

Also not sure why bullet points of the list show in IE7 but disappear it oher browsers after running the script. This is not really an issue as it can be easily fixed in CSS but I thought you should be aware of that...

Cheers,

floutag

Stop Scrolling

Would be cool to have a parameter that doesn't allow it to autoscroll by default.

Allow methods to trigger next and prev

It would be great if you can add 2 methods to get next / prev item. This will allow hooking Totem with other jquery plugins like a carousel for example.

Something like $('#totem').next(); and $('#totem').prev();

Last li element bug (margin-top property)

Hello, first sorry for my english ;)

The scroller works very well, but I saw a little bug on Chrome (14.0.835.186) and Safari (Version 5.1 (7534.48.3)) run on a Mac OsX Lion (10.7.1)

Indeed, when I run the page it works. Then I open a new tab, i stay on this tab (for 30 seconds or 1 minute). Then, when I go back to my page with "Totem", the last element stay with a margin Top negative ( margin-top:65px, in my case). The next interval fire, then the "new last li element" do the same thing, etc.

So, I did a modification that resolve my bug in the base.start_interval = function(){

I add the following lines before "base.$el.find('li:first').animate({...});" =
base.$el.find('li').clearQueue();
base.$el.find('li:not(:first)').css('marginTop','0');

I don't know if it's a good way, but it's works very well for me. I tried to reproduce the bug on your demo, but I can't, I don't know why ! :s

If you've got a better solution...

Have a good day..

Allow an option for variable row heights

Could there be an option to have row heights a fixed or variable height. If Fixed then the height of the scroller container will be determined by the number of items set in "max_items" option. But if row height is set to Variable then the height of the Container could be set with a new Height option.
Obviously if the variable row height is set then you cannot determine how many items will be displayed in the height of the scroller container, it could show three, two if one of the rows contains a lot of text or three and a half of the fourth.

Add new options to select the child element

I've modified the code to work even if the child element is not a 'li' element,

the new option 'child' can be used for searching element such as:

  1. class based element '.someclass'
  2. div element or any other html element like p, a etc

the modified code:

/*
Totem Ticker Plugin
Copyright (c) 2011 Zach Dunn / www.buildinternet.com
Released under MIT License
--------------------------
Structure based on Doug Neiner's jQuery plugin blueprint: http://starter.pixelgraphics.us/
 */
(function($) {

  if (!$.omr) {
    $.omr = new Object();
  }
  ;

  $.omr.totemticker = function(el, options) {

    var base = this;

    // Define the DOM elements
    base.el = el;
    base.$el = $(el);

    // Add a reverse reference to the DOM object
    base.$el.data("omr.totemticker", base);

    base.init = function() {
      base.options = $.extend({}, $.omr.totemticker.defaultOptions, options);

      // Define the ticker object
      base.ticker;

      // Adjust the height of ticker if specified
      base.format_ticker();

      // Setup navigation links (if specified)
      base.setup_nav();

      // Start the ticker
      base.start_interval();

      // Debugging info in console
      // base.debug_info();
    };

    base.start_interval = function() {

      // Clear out any existing interval
      clearInterval(base.ticker);

      if (base.options.direction == 'up') {
        // If the direction has been set to up
        base.ticker = setInterval(function() {
          base.$el.find(options.child + ':last').detach().prependTo(base.$el).css(
              'marginTop', '-' + base.options.row_height);
          base.$el.find(options.child + ':first').animate({
            marginTop : '0px'
          }, base.options.speed, function() {
            // Callback functions go here
          });
        }, base.options.interval);
      } else {
        // Otherwise, run the default of down
        base.ticker = setInterval(function() {

          base.$el.find(options.child + ':first').animate({
            marginTop : '-' + base.options.row_height
          }, base.options.speed, function() {
            $(this).detach().css('marginTop', '0').appendTo(base.$el);
          });

        }, base.options.interval);
      }
    }

    base.reset_interval = function() {
      clearInterval(base.ticker);
      base.start_interval();
    }

    base.stop_interval = function() {
      clearInterval(base.ticker);
    }

    base.format_ticker = function() {

      if (typeof (base.options.max_items) != "undefined"
          && base.options.max_items != null) {

        // Remove units of measurement (Should expand to cover EM and % later)
        var stripped_height = base.options.row_height.replace(/px/i, '');
        var ticker_height = stripped_height * base.options.max_items;

        base.$el.css({
          height : ticker_height + 'px',
          overflow : 'hidden'
        });

      } else {
        // No heights were specified, so just doublecheck overflow = hidden
        base.$el.css({
          overflow : 'hidden'
        })
      }

    }

    base.setup_nav = function() {

      // Stop Button
      if (typeof (base.options.stop) != "undefined"
          && base.options.stop != null) {
        $(base.options.stop).click(function() {
          base.stop_interval();
          return false;
        });
      }

      // Start Button
      if (typeof (base.options.start) != "undefined"
          && base.options.start != null) {
        $(base.options.start).click(function() {
          base.start_interval();
          return false;
        });
      }

      // Previous Button
      if (typeof (base.options.previous) != "undefined"
          && base.options.previous != null) {
        $(base.options.previous).click(
            function() {
              base.$el.find(options.child + ':last').detach().prependTo(base.$el).css(
                  'marginTop', '-' + base.options.row_height);
              base.$el.find(options.child +  ':first').animate({
                marginTop : '0px'
              }, base.options.speed, function() {
                base.reset_interval();
              });
              return false;
            });
      }

      // Next Button
      if (typeof (base.options.next) != "undefined"
          && base.options.next != null) {
        $(base.options.next).click(function() {
          base.$el.find(options.child + ':first').animate({
            marginTop : '-' + base.options.row_height
          }, base.options.speed, function() {
            $(this).detach().css('marginTop', '0px').appendTo(base.$el);
            base.reset_interval();
          });
          return false;
        });
      }

      // Stop on mouse hover
      if (typeof (base.options.mousestop) != "undefined"
          && base.options.mousestop === true) {
        base.$el.mouseenter(function() {
          base.stop_interval();
        }).mouseleave(function() {
          base.start_interval();
        });
      }

      /*
       * TO DO List ---------------- Add a continuous scrolling mode
       */

    }

    base.debug_info = function() {
      // Dump options into console
      console.log(base.options);
    }

    // Make it go!
    base.init();
  };

  $.omr.totemticker.defaultOptions = {
    message : 'Ticker Loaded', /* Disregard */
    next : null, /* ID of next button or link */
    previous : null, /* ID of previous button or link */
    stop : null, /* ID of stop button or link */
    start : null, /* ID of start button or link */
    row_height : '100px', /* Height of each ticker row in PX. Should be uniform. */
    speed : 800, /* Speed of transition animation in milliseconds */
    interval : 4000, /* Time between change in milliseconds */
    max_items : null, /*
                       * Integer for how many items to display at once. Resizes
                       * height accordingly (OPTIONAL)
                       */
    mousestop : false, /* If set to true, the ticker will stop on mouseover */
    direction : 'down', /* Direction that list will scroll */
    child: 'li' /* Child element, can be class too */
  };

  $.fn.totemticker = function(options) {
    return this.each(function() {
      (new $.omr.totemticker(this, options));
    });
  };

})(jQuery);

VicTheme team

Avoid totemizing hidden items in list

Hello,

I continuously hide/show items in the totemized list, but the script disregard that property.
Is there a way to make it cycle only between shown items? And to refresh it, when I modify the display attribute ?

Many Thanks,

Aurélien

multiple instances on page

When you have more than one Totem news ticker on a page (using the same initilising code) the next, prev, start , stop buttons trigger every instance on the page.

Is there a way to localise the buttons to trigger only that clicked instance

great little plug-in by the way!

is it work out on a tag too

hi,there.
thank you very much for your awesome plugin.i got a question there.is it work fine on a tag instead of li tag?i had try it.but when i use a tag ,it's neither scroll automatic nor scroll manual .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.