Ir al contenido principal

Entradas

Mostrando entradas de diciembre, 2015

Scroll Horizontal Selector

LESS: div .container {     width : 100 % ;     height : 100 % ;     overflow-x : scroll ;     overflow-y : hidden ;     white-space : nowrap ;     div . item {         width : 40px ;         height : 30px ;         margin-right : 1px ;         background-color : yellow;         display : inline ;     } } Javacsript: Element . prototype . hScroll = function ( options ) {     var selector = this ;     function scroll ( obj , evt ) {             var direction = evt . detail ? evt . detail * ( - 120 ) : evt . wheelDelta ;             if ( direction > 0 ) {                     direction = obj . scrollLeft - 120 ;             } else {                     direction = obj . scrollLeft + 120 ;             }             obj . scrollLeft = direction ;             evt . preventDefault ();     }     //FF doesn't recognize mousewheel as of FF3.x     var mousewheelevt = ( /Firefox/i . test ( navigator .

Delegate for older versions of Internet Explorer

// <div draggable="true"  class="resource"></div> if (document. body . addEventListener ) {     document. body . addEventListener ( 'click' , yourHandler , false ); } else {     document. body . attachEvent ( 'onclick' , yourHandler ); //for IE } function yourHandler ( e ) {     e = e || window. event ;     var target = e . target || e . srcElement ;     if ( target . className . match ( /resource/ ))     {         console . log ( target );     } }