nonlinear.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Non Linear Slider - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Non Linear Slider</h2>
  14. <p>This example shows how to create a slider with a non-linear scale.</p>
  15. <div style="margin:20px 0 50px 0;"></div>
  16. <div style="padding:2px">
  17. <input class="easyui-slider" style="width:400px" data-options="
  18. showTip:true,
  19. rule: [0,'PI/4','PI/2'],
  20. min:0,
  21. max:300,
  22. tipFormatter:function(value){
  23. return (value/300.0).toFixed(4);
  24. },
  25. converter:{
  26. toPosition:function(value,size){
  27. var opts = $(this).slider('options');
  28. return Math.asin(value/opts.max)/(Math.PI)*2*size;
  29. },
  30. toValue:function(pos,size){
  31. var opts = $(this).slider('options');
  32. return Math.sin(pos/size*Math.PI/2)*opts.max;
  33. }
  34. },
  35. onChange:function(v){
  36. var opts = $(this).slider('options');
  37. var pos = opts.converter.toPosition.call(this, v, opts.width);
  38. var p = $('<div class=point></div>').appendTo('#cc');
  39. p.css('top', v);
  40. p.css(opts.reversed?'right':'left', pos);
  41. }
  42. ">
  43. </div>
  44. <div style="margin-bottom:30px"></div>
  45. <div id="cc" class="easyui-panel" style="position:relative;width:404px;height:304px;">
  46. </div>
  47. <style scoped="scoped">
  48. .point{
  49. position:absolute;
  50. width:2px;
  51. height:2px;
  52. font-size:0;
  53. background:red;
  54. }
  55. </style>
  56. </body>
  57. </html>