1/* 2 * jQuery liMarquee v 4.6 3 * 4 * Copyright 2013, Linnik Yura | LI MASS CODE | http://masscode.ru 5 * http://masscode.ru/index.php/k2/item/44-limarquee 6 * Free to use 7 * 8 * Last Update 20.11.2014 9 */ 10(function ($) { 11 var methods = { 12 init: function (options) { 13 var p = { 14 direction: 'left', //УказÑÐ²Ð°ÐµÑ Ð½Ð°Ð¿Ñавление Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ ÑодеÑжимого конÑейнеÑа (left | right | up | down) 15 loop: -1, //ÐадаеÑ, ÑколÑко Ñаз бÑÐ´ÐµÑ Ð¿ÑокÑÑÑиваÑÑÑÑ ÑодеÑжимое. "-1" Ð´Ð»Ñ Ð±ÐµÑконеÑного воÑпÑÐ¾Ð¸Ð·Ð²ÐµÐ´ÐµÐ½Ð¸Ñ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ 16 scrolldelay: 0, //ÐелиÑина задеÑжки в миллиÑекÑÐ½Ð´Ð°Ñ Ð¼ÐµÐ¶Ð´Ñ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñми 17 scrollamount: 50, //СкоÑоÑÑÑ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ ÐºÐ¾Ð½ÑенÑа (px/sec) 18 circular: true, //ÐÑли "true" - ÑÑÑока непÑеÑÑÐ²Ð½Ð°Ñ 19 drag: true, //ÐÑли "true" - вклÑÑено пеÑеÑаÑкивание ÑÑÑоки 20 runshort: true, //ÐÑли "true" - коÑоÑÐºÐ°Ñ ÑÑÑока Ñоже "бегаеÑ", "false" - ÑÑÐ¾Ð¸Ñ Ð½Ð° меÑÑе 21 hoverstop: true, //true - ÑÑÑока оÑÑанавливаеÑÑÑ Ð¿Ñи наведении кÑÑÑоÑа мÑÑи, false - ÑÑÑока не оÑÑанавливаеÑÑÑ 22 inverthover: false, //false - ÑÑандаÑÑное поведение. ÐÑли "true" - ÑÑÑока наÑÐ¸Ð½Ð°ÐµÑ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ðµ ÑолÑко пÑи наведении кÑÑÑоÑа 23 xml: false //ÐÑÑÑ Ðº xml ÑÐ°Ð¹Ð»Ñ Ñ Ð½ÑжнÑм ÑекÑÑом 24 }; 25 if (options) { 26 $.extend(p, options); 27 } 28 29 return this.each(function () { 30 var enterEvent = 'mouseenter'; 31 var leaveEvent = 'mouseleave'; 32 if(p.inverthover){ 33 enterEvent = 'mouseleave'; 34 leaveEvent = 'mouseenter'; 35 } 36 37 38 var 39 loop = p.loop, 40 strWrap = $(this).addClass('str_wrap').data({scrollamount:p.scrollamount}), 41 fMove = false; 42 43 44 45 var strWrapStyle = strWrap.attr('style'); 46 47 if(strWrapStyle){ 48 var wrapStyleArr = strWrapStyle.split(';'); 49 var startHeight = false; 50 for(var i=0; i < wrapStyleArr.length; i++){ 51 var str = $.trim(wrapStyleArr[i]); 52 var tested = str.search(/^height/g); 53 if(tested != -1){ 54 startHeight = parseFloat(strWrap.css('height')); 55 } 56 } 57 } 58 59 var code = function () { 60 61 strWrap.off('mouseleave'); 62 strWrap.off('mouseenter'); 63 strWrap.off('mousemove'); 64 strWrap.off('mousedown'); 65 strWrap.off('mouseup'); 66 67 68 if(!$('.str_move',strWrap).length){ 69 strWrap.wrapInner($('<div>').addClass('str_move')); 70 } 71 72 var 73 strMove = $('.str_move', strWrap).addClass('str_origin'), 74 strMoveClone = strMove.clone().removeClass('str_origin').addClass('str_move_clone'), 75 time = 0; 76 77 if (!p.hoverstop) { 78 strWrap.addClass('noStop'); 79 } 80 81 var circCloneHor = function(){ 82 strMoveClone.clone().css({ 83 left:'100%', 84 right:'auto', 85 width: strMove.width() 86 }).appendTo(strMove); 87 strMoveClone.css({ 88 right: '100%', 89 left:'auto', 90 width: strMove.width() 91 }).appendTo(strMove); 92 } 93 94 var circCloneVert = function(){ 95 strMoveClone.clone().css({ 96 top: '100%', 97 bottom:'auto', 98 height: strMove.height() 99 }).appendTo(strMove); 100 strMoveClone.css({ 101 bottom: '100%', 102 top:'auto', 103 height:strMove.height() 104 }).appendTo(strMove); 105 } 106 107 108 109 if (p.direction == 'left') { 110 strWrap.height(strMove.outerHeight()) 111 if (strMove.width() > strWrap.width()) { 112 var leftPos = -strMove.width(); 113 114 if (p.circular) { 115 116 if (!p.xml) { 117 circCloneHor() 118 leftPos = -(strMove.width() + (strMove.width() - strWrap.width())); 119 } 120 } 121 if (p.xml) { 122 strMove.css({ 123 left:strWrap.width() 124 }) 125 } 126 var 127 strMoveLeft = strWrap.width(), 128 k1 = 0, 129 timeFunc1 = function () { 130 var 131 fullS = Math.abs(leftPos), 132 time = (fullS / strWrap.data('scrollamount')) * 1000; 133 if (parseFloat(strMove.css('left')) != 0) { 134 fullS = (fullS + strWrap.width()); 135 time = (fullS - (strWrap.width() - parseFloat(strMove.css('left')))) / strWrap.data('scrollamount') * 1000; 136 } 137 return time; 138 }, 139 moveFuncId1 = false, 140 moveFunc1 = function () { 141 if (loop != 0) { 142 strMove.stop(true).animate({ 143 left: leftPos 144 }, timeFunc1(), 'linear', function () { 145 $(this).css({ 146 left: strWrap.width() 147 });
148 if (loop == -1) { 149 moveFuncId1 = setTimeout(moveFunc1, p.scrolldelay); 150 } else { 151 loop--; 152 moveFuncId1 = setTimeout(moveFunc1, p.scrolldelay); 153 } 154 }); 155 } 156 }; 157 strWrap.data({ 158 moveId: moveFuncId1 , 159 moveF : moveFunc1 160 }) 161 if(!p.inverthover){ 162 moveFunc1(); 163 } 164 165 if (p.hoverstop) { 166 strWrap.on(enterEvent, function () { 167 $(this).addClass('str_active'); 168 clearTimeout(moveFuncId1); 169 strMove.stop(true); 170 }).on(leaveEvent, function () { 171 $(this).removeClass('str_active'); 172 $(this).off('mousemove'); 173 moveFunc1(); 174 }); 175 176 if (p.drag) { 177 strWrap.on('mousedown', function (e) { 178 if(p.inverthover){ 179 strMove.stop(true); 180 } 181 //drag 182 var dragLeft; 183 var dir = 1; 184 var newX; 185 var oldX = e.clientX; 186 //drag 187 188 strMoveLeft = strMove.position().left; 189 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 190 191 192 193 $(this).on('mousemove', function (e) { 194 fMove = true; 195 196 //drag 197 newX = e.clientX; 198 if(newX > oldX){ 199 dir = 1 200 }else{ 201 dir = -1 202 } 203 oldX = newX 204 dragLeft = k1 + (e.clientX - strWrap.offset().left); 205 206 if (!p.circular) { 207 if(dragLeft < -strMove.width() && dir < 0){ 208 dragLeft = strWrap.width(); 209 strMoveLeft = strMove.position().left; 210 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 211 } 212 if(dragLeft > strWrap.width() && dir > 0){ 213 dragLeft = -strMove.width(); 214 strMoveLeft = strMove.position().left; 215 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 216 } 217 }else{ 218 if(dragLeft < -strMove.width() && dir < 0){ 219 dragLeft = 0; 220 strMoveLeft = strMove.position().left; 221 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 222 } 223 if(dragLeft > 0 && dir > 0){ 224 dragLeft = -strMove.width(); 225 strMoveLeft = strMove.position().left; 226 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 227 } 228 229 } 230 231 232 strMove.stop(true).css({ 233 left: dragLeft 234 }); 235 //drag 236 237 238 239 }).on('mouseup', function () { 240 $(this).off('mousemove'); 241 if(p.inverthover){ 242 strMove.trigger('mouseenter') 243 } 244 setTimeout(function () { 245 fMove = false 246 }, 50) 247 248 }); 249 return false; 250 }) 251 .on('click', function () { 252 if (fMove) { 253 return false 254 } 255 }); 256 } else { 257 strWrap.addClass('no_drag'); 258 }; 259 } 260 } else { 261 if (p.runshort) { 262 strMove.css({ 263 left: strWrap.width() 264 });
265 var 266 strMoveLeft = strWrap.width(), 267 k1 = 0, 268 timeFunc = function () { 269 time = (strMove.width() + strMove.position().left) / strWrap.data('scrollamount') * 1000; 270 return time; 271 }; 272 var moveFunc = function () { 273 var leftPos = -strMove.width(); 274 strMove.animate({ 275 left: leftPos 276 }, timeFunc(), 'linear', function () { 277 $(this).css({ 278 left: strWrap.width() 279 }); 280 if (loop == -1) { 281 setTimeout(moveFunc, p.scrolldelay); 282 } else { 283 loop--; 284 setTimeout(moveFunc, p.scrolldelay); 285 } 286 }); 287 }; 288 strWrap.data({ 289 moveF : moveFunc 290 }) 291 if(!p.inverthover){ 292 moveFunc(); 293 } 294 if (p.hoverstop) { 295 strWrap.on(enterEvent, function () { 296 $(this).addClass('str_active'); 297 strMove.stop(true); 298 }).on(leaveEvent, function () { 299 $(this).removeClass('str_active'); 300 $(this).off('mousemove'); 301 moveFunc(); 302 }); 303 304 if (p.drag) { 305 strWrap.on('mousedown', function (e) { 306 if(p.inverthover){ 307 strMove.stop(true); 308 } 309 310 //drag 311 var dragLeft; 312 var dir = 1; 313 var newX; 314 var oldX = e.clientX; 315 //drag 316 317 strMoveLeft = strMove.position().left; 318 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 319 $(this).on('mousemove', function (e) { 320 fMove = true; 321 322 323 //drag 324 newX = e.clientX; 325 if(newX > oldX){ 326 dir = 1 327 }else{ 328 dir = -1 329 } 330 oldX = newX 331 dragLeft = k1 + (e.clientX - strWrap.offset().left); 332 333 if(dragLeft < -strMove.width() && dir < 0){ 334 dragLeft = strWrap.width(); 335 strMoveLeft = strMove.position().left; 336 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 337 } 338 if(dragLeft > strWrap.width() && dir > 0){ 339 dragLeft = -strMove.width(); 340 strMoveLeft = strMove.position().left; 341 k1 = strMoveLeft - (e.clientX - strWrap.offset().left); 342 } 343 344 345 strMove.stop(true).css({ 346 left: dragLeft 347 }); 348 349 350 351 }).on('mouseup', function () { 352 if(p.inverthover){ 353 strMove.trigger('mouseenter') 354 } 355 $(this).off('mousemove'); 356 setTimeout(function () { 357 fMove = false 358 }, 50) 359 }); 360 return false; 361 }) 362 .on('click', function () { 363 if (fMove) { 364 return false 365 } 366 }); 367 } else { 368 strWrap.addClass('no_drag'); 369 }; 370 } 371 } else { 372 strWrap.addClass('str_static'); 373 } 374 }; 375 }; 376 if (p.direction == 'right') { 377 strWrap.height(strMove.outerHeight()) 378 strWrap.addClass('str_right'); 379 strMove.css({ 380 left: -strMove.width(), 381 right: 'auto' 382 }) 383 384 if (strMove.width() > strWrap.width()) { 385 var leftPos = strWrap.width(); 386 strMove.css({ 387 left: 0 388 }) 389 if (p.circular) { 390 if (!p.xml) { 391 circCloneHor() 392 //ÐпÑеделÑем кÑайнÑÑ ÑоÑÐºÑ 393 leftPos = strMove.width(); 394 } 395 } 396 397 var 398 k2 = 0; 399 timeFunc = function () { 400 var 401 fullS = strWrap.width(), //кÑайнÑÑ ÑоÑка 402 time = (fullS / strWrap.data('scrollamount')) * 1000; //вÑÐµÐ¼Ñ 403 if (parseFloat(strMove.css('left')) != 0) { 404 fullS = (strMove.width() + strWrap.width()); 405 time = (fullS - (strMove.width() + parseFloat(strMove.css('left')))) / strWrap.data('scrollamount') * 1000; 406 } 407 return time; 408 }; 409 var moveFunc = function () { 410 411 if (loop != 0) { 412 strMove.animate({ 413 left: leftPos 414 }, timeFunc(), 'linear', function () { 415 $(this).css({ 416 left: -strMove.width() 417 });
418 if (loop == -1) { 419 setTimeout(moveFunc, p.scrolldelay); 420 } else { 421 loop--; 422 setTimeout(moveFunc, p.scrolldelay); 423 }; 424 }); 425 }; 426 }; 427 strWrap.data({ 428 moveF : moveFunc 429 }) 430 431 if(!p.inverthover){ 432 moveFunc(); 433 } 434 if (p.hoverstop) { 435 strWrap.on(enterEvent, function () { 436 $(this).addClass('str_active'); 437 strMove.stop(true); 438 }).on(leaveEvent, function () { 439 $(this).removeClass('str_active'); 440 $(this).off('mousemove'); 441 moveFunc(); 442 }); 443 444 if (p.drag) { 445 446 strWrap.on('mousedown', function (e) { 447 if(p.inverthover){ 448 strMove.stop(true); 449 } 450 451 452 //drag 453 var dragLeft; 454 var dir = 1; 455 var newX; 456 var oldX = e.clientX; 457 //drag 458 459 strMoveLeft = strMove.position().left; 460 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 461 $(this).on('mousemove', function (e) { 462 463 fMove = true; 464 465 //drag 466 newX = e.clientX; 467 if(newX > oldX){ 468 dir = 1 469 }else{ 470 dir = -1 471 } 472 oldX = newX 473 dragLeft = k2 + (e.clientX - strWrap.offset().left); 474 475 476 if (!p.circular) { 477 478 if(dragLeft < -strMove.width() && dir < 0){ 479 dragLeft = strWrap.width(); 480 strMoveLeft = strMove.position().left; 481 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 482 } 483 if(dragLeft > strWrap.width() && dir > 0){ 484 dragLeft = -strMove.width(); 485 strMoveLeft = strMove.position().left; 486 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 487 } 488 }else{ 489 if(dragLeft < -strMove.width() && dir < 0){ 490 dragLeft = 0; 491 strMoveLeft = strMove.position().left; 492 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 493 } 494 if(dragLeft > 0 && dir > 0){ 495 dragLeft = -strMove.width(); 496 strMoveLeft = strMove.position().left; 497 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 498 } 499 500 } 501 502 strMove.stop(true).css({ 503 left: dragLeft 504 }); 505 506 507 }).on('mouseup', function () { 508 if(p.inverthover){ 509 strMove.trigger('mouseenter') 510 } 511 $(this).off('mousemove'); 512 setTimeout(function () { 513 fMove = false 514 }, 50) 515 }); 516 return false; 517 }) 518 .on('click', function () { 519 if (fMove) { 520 return false 521 } 522 }); 523 } else { 524 strWrap.addClass('no_drag'); 525 }; 526 } 527 } else { 528 529 if (p.runshort) { 530 531 var k2 = 0; 532 var timeFunc = function () { 533 time = (strWrap.width() - strMove.position().left) / strWrap.data('scrollamount') * 1000; 534 return time; 535 }; 536 var moveFunc = function () { 537 var leftPos = strWrap.width(); 538 strMove.animate({ 539 left: leftPos 540 }, timeFunc(), 'linear', function () { 541 $(this).css({ 542 left: -strMove.width() 543 }); 544 if (loop == -1) { 545 setTimeout(moveFunc, p.scrolldelay); 546 } else { 547 loop--; 548 setTimeout(moveFunc, p.scrolldelay); 549 }; 550 }); 551 }; 552 553 strWrap.data({ 554 moveF : moveFunc 555 }) 556 557 if(!p.inverthover){ 558 moveFunc(); 559 } 560 if (p.hoverstop) { 561 strWrap.on(enterEvent, function () { 562 $(this).addClass('str_active'); 563 strMove.stop(true); 564 }).on(leaveEvent, function () { 565 $(this).removeClass('str_active'); 566 $(this).off('mousemove'); 567 moveFunc(); 568 });
569 570 if (p.drag) { 571 strWrap.on('mousedown', function (e) { 572 if(p.inverthover){ 573 strMove.stop(true); 574 } 575 576 //drag 577 var dragLeft; 578 var dir = 1; 579 var newX; 580 var oldX = e.clientX; 581 //drag 582 583 strMoveLeft = strMove.position().left; 584 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 585 $(this).on('mousemove', function (e) { 586 fMove = true; 587 588 589 590 //drag 591 newX = e.clientX; 592 if(newX > oldX){ 593 dir = 1 594 }else{ 595 dir = -1 596 } 597 oldX = newX 598 dragLeft = k2 + (e.clientX - strWrap.offset().left); 599 600 if(dragLeft < -strMove.width() && dir < 0){ 601 dragLeft = strWrap.width(); 602 strMoveLeft = strMove.position().left; 603 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 604 } 605 if(dragLeft > strWrap.width() && dir > 0){ 606 dragLeft = -strMove.width(); 607 strMoveLeft = strMove.position().left; 608 k2 = strMoveLeft - (e.clientX - strWrap.offset().left); 609 } 610 611 strMove.stop(true).css({ 612 left:dragLeft 613 }); 614 615 }).on('mouseup', function () { 616 if(p.inverthover){ 617 strMove.trigger('mouseenter') 618 } 619 $(this).off('mousemove'); 620 setTimeout(function () { 621 fMove = false 622 }, 50) 623 }); 624 return false; 625 }) 626 .on('click', function () { 627 if (fMove) { 628 return false 629 } 630 }); 631 } else { 632 strWrap.addClass('no_drag'); 633 }; 634 } 635 } else { 636 strWrap.addClass('str_static'); 637 } 638 }; 639 }; 640 if (p.direction == 'up') { 641 strWrap.addClass('str_vertical'); 642 643 if (strMove.height() > strWrap.height()) { 644 var topPos = -strMove.height(); 645 if (p.circular) { 646 if (!p.xml) { 647 circCloneVert(); 648 topPos = -(strMove.height() + (strMove.height() - strWrap.height())); 649 } 650 } 651 if (p.xml) { 652 strMove.css({ 653 top:strWrap.height() 654 }) 655 } 656 var 657 k2 = 0; 658 timeFunc = function () { 659 var 660 fullS = Math.abs(topPos), 661 time = (fullS / strWrap.data('scrollamount')) * 1000; 662 if (parseFloat(strMove.css('top')) != 0) { 663 fullS = (fullS + strWrap.height()); 664 time = (fullS - (strWrap.height() - parseFloat(strMove.css('top')))) / strWrap.data('scrollamount') * 1000; 665 } 666 667 return time; 668 }; 669 var moveFunc = function () { 670 if (loop != 0) { 671 strMove.animate({ 672 top: topPos 673 }, timeFunc(), 'linear', function () { 674 $(this).css({ 675 top: strWrap.height() 676 }); 677 if (loop == -1) { 678 setTimeout(moveFunc, p.scrolldelay); 679 } else { 680 loop--; 681 setTimeout(moveFunc, p.scrolldelay); 682 }; 683 }); 684 }; 685 }; 686 687 strWrap.data({ 688 moveF : moveFunc 689 }) 690 691 if(!p.inverthover){ 692 moveFunc(); 693 } 694 if (p.hoverstop) { 695 strWrap.on(enterEvent, function () { 696 $(this).addClass('str_active'); 697 strMove.stop(true); 698 }).on(leaveEvent, function () { 699 $(this).removeClass('str_active'); 700 $(this).off('mousemove'); 701 moveFunc(); 702 });
703 704 if (p.drag) { 705 strWrap.on('mousedown', function (e) { 706 if(p.inverthover){ 707 strMove.stop(true); 708 } 709 710 //drag 711 var dragTop; 712 var dir = 1; 713 var newY; 714 var oldY = e.clientY; 715 //drag 716 717 718 strMoveTop = strMove.position().top; 719 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 720 $(this).on('mousemove', function (e) { 721 722 fMove = true; 723 724 //drag 725 newY = e.clientY; 726 if(newY > oldY){ 727 dir = 1 728 }else{ 729 if(newY < oldY){ 730 dir = -1 731 } 732 } 733 oldY = newY 734 dragTop = k2 + e.clientY - strWrap.offset().top; 735 736 737 if (!p.circular){ 738 if(dragTop < -strMove.height() && dir < 0){ 739 dragTop = strWrap.height(); 740 strMoveTop = strMove.position().top; 741 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 742 } 743 if(dragTop > strWrap.height() && dir > 0){ 744 dragTop = -strMove.height(); 745 strMoveTop = strMove.position().top; 746 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 747 } 748 }else{ 749 if(dragTop < -strMove.height() && dir < 0){ 750 dragTop = 0; 751 strMoveTop = strMove.position().top; 752 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 753 } 754 if(dragTop > 0 && dir > 0){ 755 dragTop = -strMove.height(); 756 strMoveTop = strMove.position().top; 757 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 758 } 759 } 760 761 762 strMove.stop(true).css({ 763 top: dragTop 764 }); 765 //drag 766 767 768 769 770 771 772 773 774 775 776 777 778 }).on('mouseup', function () { 779 if(p.inverthover){ 780 strMove.trigger('mouseenter') 781 } 782 $(this).off('mousemove'); 783 setTimeout(function () { 784 fMove = false 785 }, 50) 786 }); 787 return false; 788 }) 789 .on('click', function () { 790 if (fMove) { 791 return false 792 } 793 }); 794 } else { 795 strWrap.addClass('no_drag'); 796 }; 797 } 798 } else { 799 if (p.runshort) { 800 strMove.css({ 801 top: strWrap.height() 802 });
803 var k2 = 0; 804 var timeFunc = function () { 805 806 time = (strMove.height() + strMove.position().top) / strWrap.data('scrollamount') * 1000; 807 808 return time; 809 }; 810 var moveFunc = function () { 811 var topPos = -strMove.height(); 812 strMove.animate({ 813 top: topPos 814 }, timeFunc(), 'linear', function () { 815 $(this).css({ 816 top: strWrap.height() 817 }); 818 if (loop == -1) { 819 setTimeout(moveFunc, p.scrolldelay); 820 } else { 821 loop--; 822 setTimeout(moveFunc, p.scrolldelay); 823 }; 824 }); 825 }; 826 strWrap.data({ 827 moveF : moveFunc 828 }) 829 if(!p.inverthover){ 830 moveFunc(); 831 } 832 if (p.hoverstop) { 833 strWrap.on(enterEvent, function () { 834 $(this).addClass('str_active'); 835 strMove.stop(true); 836 }).on(leaveEvent, function () { 837 $(this).removeClass('str_active'); 838 $(this).off('mousemove'); 839 moveFunc(); 840 }); 841 842 if (p.drag) { 843 strWrap.on('mousedown', function (e) { 844 if(p.inverthover){ 845 strMove.stop(true); 846 } 847 848 //drag 849 var dragTop; 850 var dir = 1; 851 var newY; 852 var oldY = e.clientY; 853 //drag 854 855 strMoveTop = strMove.position().top; 856 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 857 $(this).on('mousemove', function (e) { 858 859 860 fMove = true; 861 862 //drag 863 newY = e.clientY; 864 if(newY > oldY){ 865 dir = 1 866 }else{ 867 if(newY < oldY){ 868 dir = -1 869 } 870 } 871 oldY = newY 872 dragTop = k2 + e.clientY - strWrap.offset().top; 873 874 if(dragTop < -strMove.height() && dir < 0){ 875 dragTop = strWrap.height(); 876 strMoveTop = strMove.position().top; 877 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 878 } 879 if(dragTop > strWrap.height() && dir > 0){ 880 dragTop = -strMove.height(); 881 strMoveTop = strMove.position().top; 882 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 883 } 884 //*drag 885 886 strMove.stop(true).css({ 887 top: dragTop 888 }); 889 890 891 }).on('mouseup', function () { 892 if(p.inverthover){ 893 strMove.trigger('mouseenter') 894 } 895 $(this).off('mousemove'); 896 setTimeout(function () { 897 fMove = false 898 }, 50) 899 }); 900 return false; 901 }) 902 .on('click', function () { 903 if (fMove) { 904 return false 905 } 906 }); 907 } else { 908 strWrap.addClass('no_drag'); 909 }; 910 } 911 } else { 912 strWrap.addClass('str_static'); 913 } 914 }; 915 }; 916 if (p.direction == 'down') { 917 918 strWrap.addClass('str_vertical').addClass('str_down'); 919 strMove.css({ 920 top: -strMove.height(), 921 bottom: 'auto' 922 }) 923 if (strMove.height() > strWrap.height()) { 924 var topPos = strWrap.height(); 925 if (p.circular) { 926 if (!p.xml) { 927 circCloneVert(); 928 topPos = strMove.height(); 929 } 930 } 931 if (p.xml) { 932 strMove.css({ 933 top:-strMove.height() 934 }) 935 } 936 var 937 k2 = 0; 938 timeFunc = function () { 939 var 940 fullS = strWrap.height(), //кÑайнÑÑ ÑоÑка 941 time = (fullS / strWrap.data('scrollamount')) * 1000; //вÑÐµÐ¼Ñ 942 943 if (parseFloat(strMove.css('top')) != 0) { 944 fullS = (strMove.height() + strWrap.height()); 945 time = (fullS - (strMove.height() + parseFloat(strMove.css('top')))) / strWrap.data('scrollamount') * 1000; 946 } 947 return time; 948 }; 949 var moveFunc = function () { 950 951 if (loop != 0) { 952 strMove.animate({ 953 top: topPos 954 }, timeFunc(), 'linear', function () { 955 $(this).css({ 956 top: -strMove.height() 957 });
958 if (loop == -1) { 959 960 setTimeout(moveFunc, p.scrolldelay); 961 } else { 962 loop--; 963 setTimeout(moveFunc, p.scrolldelay); 964 }; 965 }); 966 }; 967 }; 968 strWrap.data({ 969 moveF : moveFunc 970 }) 971 if(!p.inverthover){ 972 moveFunc(); 973 } 974 if (p.hoverstop) { 975 strWrap.on(enterEvent, function () { 976 $(this).addClass('str_active'); 977 strMove.stop(true); 978 }).on(leaveEvent, function () { 979 $(this).removeClass('str_active'); 980 $(this).off('mousemove'); 981 moveFunc(); 982 }); 983 984 if (p.drag) { 985 strWrap.on('mousedown', function (e) { 986 if(p.inverthover){ 987 strMove.stop(true); 988 } 989 990 //drag 991 var dragTop; 992 var dir = 1; 993 var newY; 994 var oldY = e.clientY; 995 //drag 996 997 998 strMoveTop = strMove.position().top; 999 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1000 $(this).on('mousemove', function (e) { 1001 1002 fMove = true; 1003 1004 //drag 1005 newY = e.clientY; 1006 if(newY > oldY){ 1007 dir = 1 1008 }else{ 1009 if(newY < oldY){ 1010 dir = -1 1011 } 1012 } 1013 oldY = newY 1014 dragTop = k2 + e.clientY - strWrap.offset().top; 1015 1016 1017 if (!p.circular){ 1018 if(dragTop < -strMove.height() && dir < 0){ 1019 dragTop = strWrap.height(); 1020 strMoveTop = strMove.position().top; 1021 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1022 } 1023 if(dragTop > strWrap.height() && dir > 0){ 1024 dragTop = -strMove.height(); 1025 strMoveTop = strMove.position().top; 1026 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1027 } 1028 }else{ 1029 if(dragTop < -strMove.height() && dir < 0){ 1030 dragTop = 0; 1031 strMoveTop = strMove.position().top; 1032 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1033 } 1034 if(dragTop > 0 && dir > 0){ 1035 dragTop = -strMove.height(); 1036 strMoveTop = strMove.position().top; 1037 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1038 } 1039 } 1040 1041 1042 strMove.stop(true).css({ 1043 top: dragTop 1044 }); 1045 //drag 1046 1047 1048 1049 }).on('mouseup', function () { 1050 if(p.inverthover){ 1051 strMove.trigger('mouseenter') 1052 } 1053 $(this).off('mousemove'); 1054 setTimeout(function () { 1055 fMove = false 1056 }, 50) 1057 }); 1058 return false; 1059 }) 1060 .on('click', function () { 1061 if (fMove) { 1062 return false 1063 } 1064 }); 1065 } else { 1066 strWrap.addClass('no_drag'); 1067 }; 1068 } 1069 } else { 1070 if (p.runshort) { 1071 var k2 = 0; 1072 var timeFunc = function () { 1073 time = (strWrap.height() - strMove.position().top) / strWrap.data('scrollamount') * 1000; 1074 return time; 1075 }; 1076 var moveFunc = function () { 1077 var topPos = strWrap.height(); 1078 strMove.animate({ 1079 top: topPos 1080 }, timeFunc(), 'linear', function () { 1081 $(this).css({ 1082 top: -strMove.height() 1083 }); 1084 if (loop == -1) { 1085 setTimeout(moveFunc, p.scrolldelay); 1086 } else { 1087 loop--; 1088 setTimeout(moveFunc, p.scrolldelay); 1089 }; 1090 }); 1091 }; 1092 strWrap.data({ 1093 moveF : moveFunc 1094 }) 1095 if(!p.inverthover){ 1096 moveFunc(); 1097 } 1098 if (p.hoverstop) { 1099 strWrap.on(enterEvent, function () { 1100 $(this).addClass('str_active'); 1101 strMove.stop(true); 1102 }).on(leaveEvent, function () { 1103 $(this).removeClass('str_active'); 1104 $(this).off('mousemove'); 1105 moveFunc(); 1106 });
1107 1108 if (p.drag) { 1109 strWrap.on('mousedown', function (e) { 1110 if(p.inverthover){ 1111 strMove.stop(true); 1112 } 1113 1114 //drag 1115 var dragTop; 1116 var dir = 1; 1117 var newY; 1118 var oldY = e.clientY; 1119 //drag 1120 1121 strMoveTop = strMove.position().top; 1122 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1123 $(this).on('mousemove', function (e) { 1124 fMove = true; 1125 1126 //drag 1127 newY = e.clientY; 1128 if(newY > oldY){ 1129 dir = 1 1130 }else{ 1131 if(newY < oldY){ 1132 dir = -1 1133 } 1134 } 1135 oldY = newY 1136 dragTop = k2 + e.clientY - strWrap.offset().top; 1137 1138 1139 if(dragTop < -strMove.height() && dir < 0){ 1140 dragTop = strWrap.height(); 1141 strMoveTop = strMove.position().top; 1142 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1143 } 1144 if(dragTop > strWrap.height() && dir > 0){ 1145 dragTop = -strMove.height(); 1146 strMoveTop = strMove.position().top; 1147 k2 = strMoveTop - (e.clientY - strWrap.offset().top); 1148 } 1149 //*drag 1150 1151 strMove.stop(true).css({ 1152 top: dragTop 1153 }); 1154 1155 1156 1157 1158 1159 1160 1161 1162 }).on('mouseup', function () { 1163 if(p.inverthover){ 1164 strMove.trigger('mouseenter') 1165 } 1166 $(this).off('mousemove'); 1167 setTimeout(function () { 1168 fMove = false 1169 }, 50) 1170 }) 1171 return false; 1172 }) 1173 .on('click', function () { 1174 if (fMove) { 1175 return false 1176 } 1177 }); 1178 } else { 1179 strWrap.addClass('no_drag'); 1180 }; 1181 } 1182 } else { 1183 strWrap.addClass('str_static'); 1184 } 1185 }; 1186 }; 1187 1188 1189 1190 1191 } 1192 if (p.xml) { 1193 $.ajax({
1194 url: p.xml, 1195 dataType: "xml", 1196 success: function (xml) { 1197 var xmlTextEl = $(xml).find('text'); 1198 var xmlTextLength = xmlTextEl.length; 1199 for(var i = 0; i < xmlTextLength; i++){ 1200 var xmlElActive = xmlTextEl.eq(i); 1201 var xmlElContent = xmlElActive.text(); 1202 var xmlItemEl = $('<span>').text(xmlElContent).appendTo(strWrap); 1203 1204 if(p.direction == 'left' || p.direction == 'right'){ 1205 xmlItemEl.css({display:'inline-block',textAlign:'right'}); 1206 if(i > 0){ 1207 xmlItemEl.css({width:strWrap.width()+xmlItemEl.width()}); 1208 } 1209 } 1210 if(p.direction == 'down' || p.direction == 'up'){ 1211 xmlItemEl.css({display:'block',textAlign:'left'}); 1212 if(i > 0){ 1213 xmlItemEl.css({paddingTop:strWrap.height()}); 1214 } 1215 } 1216 1217 } 1218 code(); 1219 } 1220 }); 1221 } else { 1222 code(); 1223 } 1224 strWrap.data({ 1225 ini:code, 1226 startheight: startHeight 1227 }) 1228 1229 1230 1231 1232 }); 1233 }, 1234 update: function () { 1235 var el = $(this); 1236 var str_origin = $('.str_origin',el); 1237 var str_move_clone = $('.str_move_clone',el); 1238 str_origin.stop(true); 1239 str_move_clone.remove(); 1240 el.data('ini')(); 1241 }, 1242 destroy: function () { 1243 1244 var el = $(this); 1245 var elMove = $('.str_move',el); 1246 var startHeight = el.data('startheight'); 1247 1248 $('.str_move_clone',el).remove(); 1249 el.off('mouseenter'); 1250 el.off('mousedown'); 1251 el.off('mouseup'); 1252 el.off('mouseleave'); 1253 el.off('mousemove'); 1254 el.removeClass('noStop').removeClass('str_vertical').removeClass('str_active').removeClass('no_drag').removeClass('str_static').removeClass('str_right').removeClass('str_down'); 1255 1256 var elStyle = el.attr('style'); 1257 if(elStyle){ 1258 var styleArr = elStyle.split(';'); 1259 for(var i=0; i < styleArr.length; i++){ 1260 var str = $.trim(styleArr[i]); 1261 var tested = str.search(/^height/g); 1262 if(tested != -1){ 1263 styleArr[i] = ''; 1264 } 1265 } 1266 var newArr = styleArr.join(';'); 1267 var newStyle = newArr.replace(/;+/g,';') 1268 1269 if(newStyle == ';'){ 1270 el.removeAttr('style'); 1271 }else{ 1272 el.attr('style',newStyle); 1273 } 1274 1275 if(startHeight){ 1276 el.css({height:startHeight}) 1277 } 1278 } 1279 elMove.stop(true); 1280 1281 if(elMove.length){ 1282 var context = elMove.html(); 1283 elMove.remove(); 1284 el.html(context); 1285 } 1286 1287 }, 1288 pause: function(){ 1289 var el = $(this); 1290 var elMove = $('.str_move',el); 1291 elMove.stop(true); 1292 }, 1293 play: function(){ 1294 var el = $(this); 1295 $(this).off('mousemove'); 1296 el.data('moveF')(); 1297 } 1298 1299 }; 1300 $.fn.liMarquee = function (method) { 1301 if (methods[method]) { 1302 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 1303 } else if (typeof method === 'object' || !method) { 1304 return methods.init.apply(this, arguments); 1305 } else { 1306 $.error('ÐеÑод ' + method + ' в jQuery.liMarquee не ÑÑÑеÑÑвÑеÑ'); 1307 } 1308 }; 1309})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.