Loading ...
Sorry, an error occurred while loading the content.

Slider - trange behavior in FireFox

Expand Messages
  • xsolonix
    I m probably doing something wrong here, let see if someone can figure it out. THis is a simple slider (only using slideEnd event and showing the value in an
    Message 1 of 1 , Dec 1, 2006
    • 0 Attachment
      I'm probably doing something wrong here, let see if someone can
      figure it out.
      THis is a simple slider (only using slideEnd event and showing the
      value in an alert)

      Works in IE but in FireFox it loops indefinetly (the alerts keep
      poping up after the first slide)

      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head>
      <title>Untitled Page</title>
      <style type="text/css" media="screen">
      @import url("styles/style.css");
      </style>

      <script type="text/javascript" src="./ScriptLibrary/yahoo-min.js"
      ></script>
      <script type="text/javascript" src="./ScriptLibrary/event-min.js"
      ></script>
      <script type="text/javascript" src="./ScriptLibrary/dom-min.js"
      ></script>
      <script type="text/javascript" src="./ScriptLibrary/dragdrop-min.js"
      ></script>
      <script type="text/javascript" src="./ScriptLibrary/logger-min.js"
      ></script>
      <script type="text/javascript" src="./ScriptLibrary/animation-
      min.js" ></script>
      <script type="text/javascript" src="./ScriptLibrary/slider-min.js"
      ></script>
      </head>
      <body>
      <div id="horizWrapper">
      <div id="horizBGDiv" tabindex="0" x2:role="role:slider"
      state:valuenow="0" state:valuemin="0" state:valuemax="200"
      title="Horizontal Slider" >
      <div id="horizHandleDiv" ><img alt="s"
      src="Images/horizSlider.png" /></div>
      </div>
      <div id="horizValueDiv"></div>


      </div>
      <script type="text/javascript">
      //<![CDATA[

      YAHOO.example.Sliders = function() {

      var Dom = YAHOO.util.Dom;
      var Event = YAHOO.util.Event;

      var xslider;

      function handleHorizSliderKey(e) {
      //YAHOO.log("horizontal slider keypress");

      var valueNow = xslider.getValue();
      var valueMin = xslider.thumb.rightConstraint;
      var valueMax = xslider.thumb.leftConstraint;
      var delta = 0;
      var kc = Event.getCharCode(e);

      //YAHOO.log("keycode: " + kc);

      if (kc == YAHOO.util.Key.DOM_VK_LEFT) {
      delta = -20;
      } else if (kc == YAHOO.util.Key.DOM_VK_RIGHT) {
      delta = 20;
      } else if (kc == YAHOO.util.Key.DOM_VK_HOME) {
      delta = -( valueNow - valueMin );
      } else if (kc == YAHOO.util.Key.DOM_VK_END) {
      delta = valueMax - valueNow;
      } else {
      return true;
      }

      valueNow += delta;

      var sliderBg = Dom.get("horizBGDiv");
      if (sliderBg.setAttributeNS) {
      sliderBg.setAttributeNS("http://www.w3.org/2005/07/aaa",
      "valuenow", valueNow);
      }

      Event.stopEvent(e);
      return false;
      }




      var initHoriz = function() {

      var bg="horizBGDiv",thumb="horizHandleDiv",valFld="horizVal";

      xslider = YAHOO.widget.Slider.getHorizSlider(bg,
      thumb, 0, 200);//, 25);

      xslider.subscribe("slideEnd", function() {



      var val = this.getValue();
      alert(val);

      });



      Event.on(bg, "keydown", handleHorizSliderKey);
      Event.on(bg, "keypress", Event.preventDefault);
      };

      return {

      init: function() {
      initHoriz();
      },



      updateHoriz:function() {

      return false;
      }

      }
      }();

      YAHOO.util.Event.on(window, "load", YAHOO.example.Sliders.init);
      //]]>
      </script>
      </body>
      </html>

      Thanks

      Martin
    Your message has been successfully submitted and would be delivered to recipients shortly.