rendu
This commit is contained in:
@@ -0,0 +1,231 @@
|
||||
let canvas = document.getElementById('scene');
|
||||
let ctx = canvas.getContext("2d");
|
||||
|
||||
|
||||
let resizeCanvas = () => {
|
||||
canvas.width = 1275;
|
||||
canvas.height = 300;
|
||||
}
|
||||
resizeCanvas()
|
||||
|
||||
|
||||
let onResize = (event) => {
|
||||
resizeCanvas()
|
||||
}
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
// ctx.fillStyle = "green";
|
||||
// ctx.fillRect(300, 300, 100, 100);
|
||||
|
||||
|
||||
|
||||
|
||||
class Boule {
|
||||
constructor(x, y, s) {
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
this.pos = {
|
||||
x: x,
|
||||
y: y
|
||||
}
|
||||
this.size = s
|
||||
this.vx = -2+Math.random()*4;
|
||||
this.vy = -2+Math.random()*4;
|
||||
// this.color = 'hsl(360, 50%, 50%)'
|
||||
this.color = {
|
||||
h:360,
|
||||
s:50,
|
||||
l:50
|
||||
}
|
||||
this.img = new Image();
|
||||
this.img.src = "/user/pages/01.home/point.png";
|
||||
|
||||
}
|
||||
|
||||
draw(){
|
||||
// console.log('draw', this);
|
||||
// ctx.beginPath();
|
||||
// ctx.fillStyle = `hsl(${this.color.h},${this.color.s}%,${this.color.l}%)`;
|
||||
// ctx.arc(this.pos.x, this.pos.y, this.size, 0, 2 * Math.PI);
|
||||
// // ctx.fillRect(300, 300, 100, 100);
|
||||
// ctx.fill();
|
||||
// ctx.closePath();
|
||||
|
||||
// this.img.onload = () => {
|
||||
// // console.log('img, x, y', this.img, this.pos.x, this.pos.y);
|
||||
ctx.drawImage(this.img, this.pos.x, this.pos.y, 3*this.size, 5*this.size);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
move(){
|
||||
this.pos.x += this.vx;
|
||||
this.pos.y += this.vy;
|
||||
|
||||
if(this.pos.x >= canvas.width || this.pos.x <= 0){
|
||||
this.vx *= -1;
|
||||
}
|
||||
if(this.pos.y >= canvas.height || this.pos.y <= 0){
|
||||
this.vy *= -1;
|
||||
}
|
||||
|
||||
this.draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let boules = [];
|
||||
let maboule;
|
||||
function createBoule(){
|
||||
maboule = new Boule(
|
||||
canvas.width / 2, // Math.random()*canvas.width,
|
||||
canvas.height / 2, // Math.random()*canvas.height,
|
||||
10+Math.random()*30
|
||||
);
|
||||
maboule.draw();
|
||||
boules.push(maboule);
|
||||
}
|
||||
|
||||
// for (let index = 0; index < 10000; index++) {
|
||||
// createBoule();
|
||||
// }
|
||||
|
||||
setInterval(()=>{
|
||||
createBoule();
|
||||
}, 1000)
|
||||
|
||||
let anime = () => {
|
||||
ctx.clearRect(0,0, canvas.width, canvas.height)
|
||||
// boules.forEach((boule_a) => {
|
||||
for (let i = 0; i < boules.length; i++) {
|
||||
let boule_a = boules[i];
|
||||
for (let j = i+1; j < boules.length; j++) {
|
||||
let boule_b = boules[j];
|
||||
// distance entre les centre des boules
|
||||
let dist = Math.sqrt(
|
||||
Math.pow(boule_b.pos.x - boule_a.pos.x, 2) +
|
||||
Math.pow(boule_b.pos.y - boule_a.pos.y, 2)
|
||||
);
|
||||
// console.log('dist', dist);
|
||||
|
||||
if(dist < boule_a.size+boule_b.size){
|
||||
// console.log('ça touche');
|
||||
|
||||
// distance inferieure a la somme des deux rayons
|
||||
// ça touche
|
||||
// boule_a.vx *= -1;
|
||||
// boule_a.vy *= -1;
|
||||
// boule_b.vx *= -1;
|
||||
// boule_b.vy *= -1;
|
||||
|
||||
nx = (boule_b.pos.x - boule_a.pos.x)/dist;
|
||||
ny = (boule_b.pos.y - boule_a.pos.y)/dist;
|
||||
|
||||
vA_n = boule_a.vx*nx + boule_a.vy*ny
|
||||
vB_n = boule_b.vx*nx + boule_b.vy*ny
|
||||
|
||||
boule_a.vx += (vB_n - vA_n) * nx
|
||||
boule_a.vy += (vB_n - vA_n) * ny
|
||||
boule_b.vx += (vA_n - vB_n) * nx
|
||||
boule_b.vy += (vA_n - vB_n) * ny
|
||||
boule_a.move();
|
||||
boule_b.move();
|
||||
}
|
||||
}
|
||||
boule_a.move();
|
||||
}
|
||||
|
||||
|
||||
|
||||
window.requestAnimationFrame(anime);
|
||||
}
|
||||
|
||||
window.requestAnimationFrame(anime);
|
||||
|
||||
|
||||
let onMouseMove = (event) => {
|
||||
// console.log('event', event);
|
||||
// h 0 -> 360
|
||||
// x 0 -> canvas.width
|
||||
let h = 360 * (event.x / canvas.width);
|
||||
// console.log('h', h);
|
||||
|
||||
let s = 100 * (event.y / canvas.height)
|
||||
console.log('s', s);
|
||||
|
||||
boules.forEach(boule => {
|
||||
boule.color.h = h;
|
||||
boule.color.s = s;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
var greetings = [ "Essaye plus tard",
|
||||
"Ma femme me manque",
|
||||
"Essaye encore",
|
||||
"Pas d'avis",
|
||||
"C'est ton destin",
|
||||
"Le sort en est jeté",
|
||||
"Une chance sur deux",
|
||||
"Repose ta question",
|
||||
"D'après moi oui",
|
||||
"C'est certain",
|
||||
"Oui absolument",
|
||||
"Tu peux compter dessus",
|
||||
"Sans aucun doute",
|
||||
"Très probable",
|
||||
"Oui",
|
||||
"C'est bien parti",
|
||||
"C'est non",
|
||||
"Peu probable",
|
||||
"Faut pas rêver",
|
||||
"N'y compte pas ",
|
||||
"Impossible",
|
||||
"Je n'ai plus d'espoir",
|
||||
"Je suis un steak haché",
|
||||
"Vous savez, moi je ne crois pas qu’il y ait de bonne ou de mauvaise situation. Moi, si je devais résumer ma vie aujourd’hui avec vous, je dirais que c’est d’abord des rencontres. Des gens qui m’ont tendu la main, peut-être à un moment où je ne pouvais pas, où j’étais seul chez moi. Et c’est assez curieux de se dire que les hasards, les rencontres forgent une destinée… Parce que quand on a le goût de la chose, quand on a le goût de la chose bien faite, le beau geste, parfois on ne trouve pas l’interlocuteur en face je dirais, le miroir qui vous aide à avancer. Alors ça n’est pas mon cas, comme je disais là, puisque moi au contraire, j’ai pu : et je dis merci à la vie, je lui dis merci, je chante la vie, je danse la vie… je ne suis qu’amour ! Et finalement, quand beaucoup de gens aujourd’hui me disent « Mais comment fais-tu pour avoir cette humanité ? », et bien je leur réponds très simplement, je leur dis que c’est ce goût de l’amour ce goût donc qui m’a poussé aujourd’hui à entreprendre une construction mécanique, mais demain qui sait ? Peut-être simplement à me mettre au service de la communauté, à faire le don, le don de soi… "
|
||||
];
|
||||
|
||||
|
||||
//setInterval(changeText, 2000);
|
||||
|
||||
|
||||
//function changeText()
|
||||
//{
|
||||
// var greeting_id = Math.floor(Math.random() * greetings.length);
|
||||
// document.getElementById('speech').innerHTML = greetings[greeting_id];
|
||||
// console.log(greeting_id)
|
||||
//}
|
||||
|
||||
|
||||
//function clickHandler() {
|
||||
// const caca = document.getElementById('caca');
|
||||
// window.onload = function() {
|
||||
// var el = document.getElementById('speech');
|
||||
// el.textContent = greetings[greeting_id]
|
||||
// }
|
||||
//}
|
||||
|
||||
//function changeText() {
|
||||
// document.getElementById("speech").innerHTML = "Text Changed!";
|
||||
//}
|
||||
|
||||
|
||||
|
||||
function changeText() {
|
||||
const randomIndex = Math.floor(Math.random() * greetings.length);
|
||||
const speechDiv = document.getElementById("speech");
|
||||
speechDiv.textContent = greetings[randomIndex];
|
||||
}
|
||||
|
||||
document.getElementById("caca").addEventListener("click", () => {
|
||||
changeText();
|
||||
});
|
||||
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
!function t(e,n,r){function o(s,u){if(!n[s]){if(!e[s]){var l="function"==typeof require&&require;if(!u&&l)return l(s,!0);if(i)return i(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[s]={exports:{}};e[s][0].call(p.exports,function(t){var n=e[s][1][t];return o(n?n:t)},p,p.exports,t,e,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){var r,o=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)};!function(t){function e(t){return[].slice.call(t)}function n(t,e,n){if(window.CustomEvent)var r=new CustomEvent(e,{detail:n});else{var r=document.createEvent("CustomEvent");r.initCustomEvent(e,!0,!0,n)}return t.dispatchEvent(r)}var r={rulerClassName:"bricklayer-column-sizer",columnClassName:"bricklayer-column"},i=function(){function t(t){this.element=document.createElement("div"),this.element.className=t}return t.prototype.destroy=function(){this.element.parentNode.removeChild(this.element)},t}(),s=function(t){function e(){t.apply(this,arguments)}return o(e,t),e.prototype.getWidth=function(){this.element.setAttribute("style","\n display: block;\n visibility: hidden !important;\n top: -1000px !important;\n ");var t=this.element.offsetWidth;return this.element.removeAttribute("style"),t},e}(i),u=function(t){function e(){t.apply(this,arguments)}return o(e,t),e}(i),l=function(){function t(t,e){void 0===e&&(e=r),this.element=t,this.options=e,this.build(),this.buildResponsive()}return t.prototype.append=function(t){var n=this;if(Array.isArray(t))return void t.forEach(function(t){return n.append(t)});var r=this.findMinHeightColumn();this.elements=e(this.elements).concat([t]),this.applyPosition("append",r,t)},t.prototype.prepend=function(t){var n=this;if(Array.isArray(t))return void t.forEach(function(t){return n.prepend(t)});var r=this.findMinHeightColumn();this.elements=[t].concat(e(this.elements)),this.applyPosition("prepend",r,t)},t.prototype.on=function(t,e){return this.element.addEventListener("bricklayer."+t,e),this},t.prototype.redraw=function(){var t=this.columnCount;this.checkColumnCount(!1),this.reorderElements(t),n(this.element,"bricklayer.redraw",{columnCount:t})},t.prototype.destroy=function(){var t=this;this.ruler.destroy(),e(this.elements).forEach(function(e){return t.element.appendChild(e)}),e(this.getColumns()).forEach(function(t){return t.parentNode.removeChild(t)}),n(this.element,"bricklayer.destroy",{})},t.prototype.build=function(){this.ruler=new s(this.options.rulerClassName),this.elements=this.getElementsInOrder(),this.element.insertBefore(this.ruler.element,this.element.firstChild)},t.prototype.buildResponsive=function(){var t=this;window.addEventListener("resize",function(e){return t.checkColumnCount()}),this.checkColumnCount(),this.on("breakpoint",function(e){return t.reorderElements(e.detail.columnCount)}),this.columnCount>=1&&this.reorderElements(this.columnCount)},t.prototype.getColumns=function(){return this.element.querySelectorAll(":scope > ."+this.options.columnClassName)},t.prototype.findMinHeightColumn=function(){var t=e(this.getColumns()),n=t.map(function(t){return t.offsetHeight}),r=Math.min.apply(null,n);return t[n.indexOf(r)]},t.prototype.getElementsInOrder=function(){return this.element.querySelectorAll(":scope > *:not(."+this.options.columnClassName+"):not(."+this.options.rulerClassName+")")},t.prototype.checkColumnCount=function(t){void 0===t&&(t=!0);var e=this.getColumnCount();this.columnCount!==e&&(t&&n(this.element,"bricklayer.breakpoint",{columnCount:e}),this.columnCount=e)},t.prototype.reorderElements=function(t){var n=this;void 0===t&&(t=1),(t==1/0||1>t)&&(t=1);for(var r=e(this.elements).map(function(t){var e=t.parentNode?t.parentNode.removeChild(t):t;return e}),o=this.getColumns(),i=0;i<o.length;i++)o[i].parentNode.removeChild(o[i]);for(var i=0;t>i;i++){var s=new u(this.options.columnClassName).element;this.element.appendChild(s)}r.forEach(function(t){var e=n.findMinHeightColumn();e.appendChild(t)})},t.prototype.getColumnCount=function(){var t=this.element.offsetWidth,e=this.ruler.getWidth();return Math.round(t/e)},t.prototype.applyPosition=function(t,e,r){var o=this,i=function(i){var s=i+t.charAt(0).toUpperCase()+t.substr(1);n(o.element,"bricklayer."+s,{item:r,column:e})};switch(i("before"),t){case"append":e.appendChild(r);break;case"prepend":e.insertBefore(r,e.firstChild)}i("after")},t}();t.Container=l}(r||(r={})),function(t,n){"function"==typeof define&&define.amd?define(function(){return n()}):"undefined"!=typeof window&&t===window?t.Bricklayer=n():"object"==typeof e&&e.exports&&(e.exports=n())}("undefined"!=typeof window?window:this,function(){return r.Container})},{}]},{},[1]);
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
treeMenu - jQuery plugin
|
||||
version: 0.6
|
||||
|
||||
Copyright 2014 Stepan Krapivin
|
||||
|
||||
*/
|
||||
(function($){
|
||||
$.fn.treemenu = function(options) {
|
||||
options = options || {};
|
||||
options.delay = options.delay || 0;
|
||||
options.openActive = options.openActive || false;
|
||||
options.closeOther = options.closeOther || false;
|
||||
options.activeSelector = options.activeSelector || ".active";
|
||||
|
||||
this.addClass("treemenu");
|
||||
|
||||
if (!options.nonroot) {
|
||||
this.addClass("treemenu-root");
|
||||
}
|
||||
|
||||
options.nonroot = true;
|
||||
|
||||
this.find("> li").each(function() {
|
||||
e = $(this);
|
||||
var subtree = e.find('> ul');
|
||||
var button = e.find('.toggler').eq(0);
|
||||
|
||||
if(button.length == 0) {
|
||||
// create toggler
|
||||
var button = $('<span>');
|
||||
button.addClass('toggler');
|
||||
e.prepend(button);
|
||||
}
|
||||
|
||||
if(subtree.length > 0) {
|
||||
subtree.hide();
|
||||
|
||||
e.addClass('tree-closed');
|
||||
|
||||
e.find(button).click(function() {
|
||||
var li = $(this).parent('li');
|
||||
|
||||
if (options.closeOther && li.hasClass('tree-closed')) {
|
||||
var siblings = li.parent('ul').find("li:not(.tree-empty)");
|
||||
siblings.removeClass("tree-opened");
|
||||
siblings.addClass("tree-closed");
|
||||
siblings.removeClass(options.activeSelector);
|
||||
siblings.find('> ul').slideUp(options.delay);
|
||||
}
|
||||
|
||||
li.find('> ul').slideToggle(options.delay);
|
||||
li.toggleClass('tree-opened');
|
||||
li.toggleClass('tree-closed');
|
||||
li.toggleClass(options.activeSelector);
|
||||
});
|
||||
|
||||
$(this).find('> ul').treemenu(options);
|
||||
} else {
|
||||
$(this).addClass('tree-empty');
|
||||
}
|
||||
});
|
||||
|
||||
if (options.openActive) {
|
||||
var cls = this.attr("class");
|
||||
|
||||
this.find(options.activeSelector).each(function(){
|
||||
var el = $(this).parent();
|
||||
|
||||
while (el.attr("class") !== cls) {
|
||||
el.find('> ul').show();
|
||||
if(el.prop("tagName") === 'UL') {
|
||||
el.show();
|
||||
} else if (el.prop("tagName") === 'LI') {
|
||||
el.removeClass('tree-closed');
|
||||
el.addClass("tree-opened");
|
||||
el.show();
|
||||
}
|
||||
|
||||
el = el.parent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,9 @@
|
||||
/* scopeQuerySelectorShim.js
|
||||
*
|
||||
* Copyright (C) 2015 Larry Davis
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the BSD license. See the LICENSE file for details.
|
||||
*/
|
||||
!function(){function a(a,c){var e=a[c];a[c]=function(a){var c,f=!1,g=!1;return a.match(d)?(a=a.replace(d,""),this.parentNode||(b.appendChild(this),g=!0),parentNode=this.parentNode,this.id||(this.id="rootedQuerySelector_id_"+(new Date).getTime(),f=!0),c=e.call(parentNode,"#"+this.id+" "+a),f&&(this.id=""),g&&b.removeChild(this),c):e.call(this,a)}}if(!HTMLElement.prototype.querySelectorAll)throw new Error("rootedQuerySelectorAll: This polyfill can only be used with browsers that support querySelectorAll");var b=document.createElement("div");try{b.querySelectorAll(":scope *")}catch(c){var d=/^\s*:scope/gi;a(HTMLElement.prototype,"querySelector"),a(HTMLElement.prototype,"querySelectorAll")}}();
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Single Page Nav Plugin
|
||||
* Copyright (c) 2014 Chris Wojcik <hello@chriswojcik.net>
|
||||
* Dual licensed under MIT and GPL.
|
||||
* @author Chris Wojcik
|
||||
* @version 1.2.0
|
||||
*/
|
||||
if(typeof Object.create!=="function"){Object.create=function(e){function t(){}t.prototype=e;return new t}}(function(e,t,n,r){"use strict";var i={init:function(n,r){this.options=e.extend({},e.fn.singlePageNav.defaults,n);this.container=r;this.$container=e(r);this.$links=this.$container.find("a");if(this.options.filter!==""){this.$links=this.$links.filter(this.options.filter)}this.$window=e(t);this.$htmlbody=e("html, body");this.$links.on("click.singlePageNav",e.proxy(this.handleClick,this));this.didScroll=false;this.checkPosition();this.setTimer()},handleClick:function(t){var n=this,r=t.currentTarget,i=e(r.hash);t.preventDefault();if(i.length){n.clearTimer();if(typeof n.options.beforeStart==="function"){n.options.beforeStart()}n.setActiveLink(r.hash);n.scrollTo(i,function(){if(n.options.updateHash&&history.pushState){history.pushState(null,null,r.hash)}n.setTimer();if(typeof n.options.onComplete==="function"){n.options.onComplete()}})}},scrollTo:function(e,t){var n=this;var r=n.getCoords(e).top;var i=false;n.$htmlbody.stop().animate({scrollTop:r},{duration:n.options.speed,easing:n.options.easing,complete:function(){if(typeof t==="function"&&!i){t()}i=true}})},setTimer:function(){var e=this;e.$window.on("scroll.singlePageNav",function(){e.didScroll=true});e.timer=setInterval(function(){if(e.didScroll){e.didScroll=false;e.checkPosition()}},250)},clearTimer:function(){clearInterval(this.timer);this.$window.off("scroll.singlePageNav");this.didScroll=false},checkPosition:function(){var e=this.$window.scrollTop();var t=this.getCurrentSection(e);this.setActiveLink(t)},getCoords:function(e){return{top:Math.round(e.offset().top)-this.options.offset}},setActiveLink:function(e){var t=this.$container.find("a[href$='"+e+"']");if(!t.hasClass(this.options.currentClass)){this.$links.removeClass(this.options.currentClass);t.addClass(this.options.currentClass)}},getCurrentSection:function(t){var n,r,i,s;for(n=0;n<this.$links.length;n++){r=this.$links[n].hash;if(e(r).length){i=this.getCoords(e(r));if(t>=i.top-this.options.threshold){s=r}}}return s||this.$links[0].hash}};e.fn.singlePageNav=function(e){return this.each(function(){var t=Object.create(i);t.init(e,this)})};e.fn.singlePageNav.defaults={offset:0,threshold:120,speed:400,currentClass:"current",easing:"swing",updateHash:false,filter:"",onComplete:false,beforeStart:false}})(jQuery,window,document);
|
||||
@@ -0,0 +1,59 @@
|
||||
var isTouch = window.DocumentTouch && document instanceof DocumentTouch;
|
||||
|
||||
function scrollHeader() {
|
||||
// Has scrolled class on header
|
||||
var zvalue = $(document).scrollTop();
|
||||
if ( zvalue > 75 )
|
||||
$("#header").addClass("scrolled");
|
||||
else
|
||||
$("#header").removeClass("scrolled");
|
||||
}
|
||||
|
||||
function parallaxBackground() {
|
||||
$('.parallax').css('background-positionY', ($(window).scrollTop() * 0.3) + 'px');
|
||||
}
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
scrollHeader();
|
||||
|
||||
// Scroll Events
|
||||
if (!isTouch){
|
||||
$(document).scroll(function() {
|
||||
scrollHeader();
|
||||
parallaxBackground();
|
||||
});
|
||||
};
|
||||
|
||||
// Touch scroll
|
||||
$(document).on({
|
||||
'touchmove': function(e) {
|
||||
scrollHeader(); // Replace this with your code.
|
||||
}
|
||||
});
|
||||
|
||||
//Smooth scroll to start
|
||||
$('#to-start').click(function(){
|
||||
var start_y = $('#start').position().top;
|
||||
var header_offset = 45;
|
||||
window.scroll({ top: start_y - header_offset, left: 0, behavior: 'smooth' });
|
||||
return false;
|
||||
});
|
||||
|
||||
//Smooth scroll to top
|
||||
$('#to-top').click(function(){
|
||||
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
|
||||
return false;
|
||||
});
|
||||
|
||||
// Responsive Menu
|
||||
$('#toggle').click(function () {
|
||||
$(this).toggleClass('active');
|
||||
$('#overlay').toggleClass('open');
|
||||
$('body').toggleClass('mobile-nav-open');
|
||||
});
|
||||
|
||||
// Tree Menu
|
||||
$(".tree").treemenu({delay:300});
|
||||
|
||||
});
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* smoothscroll polyfill - v0.3.4
|
||||
* https://iamdustan.github.io/smoothscroll
|
||||
* 2016 (c) Dustan Kasten, Jeremias Menichelli - MIT License
|
||||
*/
|
||||
!function(o,t,l){"use strict";function e(){function e(o,t){this.scrollLeft=o,this.scrollTop=t}function r(o){return.5*(1-Math.cos(Math.PI*o))}function n(o){if("object"!=typeof o||null===o||o.behavior===l||"auto"===o.behavior||"instant"===o.behavior)return!0;if("object"==typeof o&&"smooth"===o.behavior)return!1;throw new TypeError("behavior not valid")}function c(l){var e,r,n;do l=l.parentNode,e=l===t.body,r=l.clientHeight<l.scrollHeight||l.clientWidth<l.scrollWidth,n="visible"===o.getComputedStyle(l,null).overflow;while(!e&&(!r||n));return e=r=n=null,l}function i(t){t.frame=o.requestAnimationFrame(i.bind(o,t));var l,e,n,c=u(),s=(c-t.startTime)/f;return s=s>1?1:s,l=r(s),e=t.startX+(t.x-t.startX)*l,n=t.startY+(t.y-t.startY)*l,t.method.call(t.scrollable,e,n),e===t.x&&n===t.y?void o.cancelAnimationFrame(t.frame):void 0}function s(l,r,n){var c,s,a,f,d,h=u();l===t.body?(c=o,s=o.scrollX||o.pageXOffset,a=o.scrollY||o.pageYOffset,f=p.scroll):(c=l,s=l.scrollLeft,a=l.scrollTop,f=e),d&&o.cancelAnimationFrame(d),i({scrollable:c,method:f,startTime:h,startX:s,startY:a,x:r,y:n,frame:d})}if(!("scrollBehavior"in t.documentElement.style)){var a=o.HTMLElement||o.Element,f=468,p={scroll:o.scroll||o.scrollTo,scrollBy:o.scrollBy,scrollIntoView:a.prototype.scrollIntoView},u=o.performance&&o.performance.now?o.performance.now.bind(o.performance):Date.now;o.scroll=o.scrollTo=function(){return n(arguments[0])?void p.scroll.call(o,arguments[0].left||arguments[0],arguments[0].top||arguments[1]):void s.call(o,t.body,~~arguments[0].left,~~arguments[0].top)},o.scrollBy=function(){return n(arguments[0])?void p.scrollBy.call(o,arguments[0].left||arguments[0],arguments[0].top||arguments[1]):void s.call(o,t.body,~~arguments[0].left+(o.scrollX||o.pageXOffset),~~arguments[0].top+(o.scrollY||o.pageYOffset))},a.prototype.scrollIntoView=function(){if(n(arguments[0]))return void p.scrollIntoView.call(this,arguments[0]||!0);var l=c(this),e=l.getBoundingClientRect(),r=this.getBoundingClientRect();l!==t.body?(s.call(this,l,l.scrollLeft+r.left-e.left,l.scrollTop+r.top-e.top),o.scrollBy({left:e.left,top:e.top,behavior:"smooth"})):o.scrollBy({left:r.left,top:r.top,behavior:"smooth"})}}}"object"==typeof exports?module.exports={polyfill:e}:e()}(window,document);
|
||||
Reference in New Issue
Block a user