Advertisement
Dim4eBeBrat

Custom Tooltip Animation JavaScript

Dec 14th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 4.09 KB | None | 0 0
  1. <!doctype html>
  2.  
  3. <html lang="en">
  4. <head>
  5.     <meta charset="utf-8" />
  6.     <title>Задача 1</title>
  7.     <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  8.     <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  9.     <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  10.       <style>
  11.     .ui-tooltip, .arrow:after {
  12.         background: black;
  13.         border: 2px solid white;
  14.     }
  15.     .ui-tooltip {
  16.         padding: 10px 20px;
  17.         color: white;
  18.         border-radius: 20px;
  19.         font: bold 14px "Helvetica Neue", Sans-Serif;
  20.         text-transform: uppercase;
  21.         box-shadow: 0 0 7px black;
  22.     }
  23.     .arrow {
  24.         width: 70px;
  25.         height: 16px;
  26.         overflow: hidden;
  27.         position: absolute;
  28.         left: 50%;
  29.         margin-left: -35px;
  30.         bottom: -16px;
  31.     }
  32.     .arrow.top {
  33.         top: -16px;
  34.         bottom: auto;
  35.     }
  36.     .arrow.left {
  37.         left: 20%;
  38.     }
  39.     .arrow:after {
  40.         content: "";
  41.         position: absolute;
  42.         left: 20px;
  43.         top: -20px;
  44.         width: 25px;
  45.         height: 25px;
  46.         box-shadow: 6px 5px 9px -9px black;
  47.         -webkit-transform: rotate(45deg);
  48.         -moz-transform: rotate(45deg);
  49.         -ms-transform: rotate(45deg);
  50.         -o-transform: rotate(45deg);
  51.         transform: rotate(45deg);
  52.     }
  53.     .arrow.top:after {
  54.         bottom: -20px;
  55.         top: auto;
  56.     }
  57.          
  58.     </style>
  59.    
  60.     <script>
  61.         $(document).ready(function(){
  62.            
  63.             $(document).change(function(){
  64.                  
  65.                 if($("#effect").val() == "myAnimation"){
  66.                    $( "#ime" ).tooltip({
  67.                            open: function (event, ui) {
  68.                                ui.tooltip.animate({
  69.                                    left: 890
  70.                                }, 800,
  71.                                      function () {
  72.                                ui.tooltip.animate({
  73.                                 left: 721.5
  74.                                }, 800);
  75.                             });}
  76.                         ,
  77.                             hide: {
  78.                                 effect: "fade",
  79.                                 duration: 100
  80.                             }
  81.                     });
  82.                    }
  83.             else {  
  84.                 $( "#ime" ).stop(true, true);
  85.                 $( "#ime" ).tooltip({
  86.                   show: {
  87.                     effect: $( "#effect" ).val(),
  88.                     delay: 50
  89.                   },
  90.                   position: {
  91.                     my: "center bottom-20",
  92.                     at: "left top",
  93.                     using: function( position, feedback ) {
  94.                       $( this ).css( position );
  95.                       $( "<div>" )
  96.                         .addClass( "arrow" )
  97.                         .addClass( feedback.vertical )
  98.                         .addClass( feedback.horizontal )
  99.                         .appendTo( this );
  100.                     }
  101.                   }
  102.                 });
  103.             }
  104.         });
  105.     });
  106.    
  107.     </script>
  108.    
  109. </head>
  110. <body >
  111.  
  112.  
  113.  <div style="width:400px; margin:100px auto;">
  114.  <select id="effect">
  115.  <option value="blind">Blind</option>
  116.   <option value="bounce">Bounce</option>
  117.   <option value="clip">Clip</option>
  118.   <option value="drop">Drop</option>
  119.   <option value="explode">Explode</option>
  120.   <option value="fade">Fade</option>
  121.   <option value="fold">Fold</option>
  122.   <option value="highlight">Highlight</option>
  123.   <option value="puff">Puff</option>
  124.   <option value="pulsate">Pulsate</option>
  125.   <option value="scale">Scale</option>
  126.   <option value="shake">Shake</option>
  127.   <option value="size">Size</option>
  128.   <option value="slide">Slide</option>
  129.   <option value="transfer">Transfer</option>
  130.   <option value="myAnimation">My animation</option>
  131.   </select>
  132.   <br/><br/>
  133.  <div id="okay" style="width:100px">Име:</div><input id="ime" class="tooltip" name="ime" style="width:200px" title="Име"/>
  134.  
  135.  </div>
  136. </body>
  137. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement