X   Сообщение сайта
(Сообщение закроется через 3 секунды)



 

Здравствуйте, гость (

| Вход | Регистрация )

Открыть тему
Тема закрыта
> Не работает скрипт
serhiokrava
serhiokrava
Topic Starter сообщение 28.10.2018, 22:24; Ответить: serhiokrava
Сообщение #1


Уважаемые знатоки - подскажите, пожалуйста, почему не работают скрипты на сайте?

Хочу поставить этот скрипт - пример - что уже с ним не делал - не работает.

HTML код - вставлял и в страницу, и в header.php

<div id="container">
<div id="c-container">
<canvas id="c">Sorry.</canvas>
</div>
<div id="c2-container">
<canvas id="c2">Sorry.</canvas>
</div>

</div>

CSS код - то же самое - и в страницу, и в header.php -

<style type="text/css">
@import 'https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i';

body,
html {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
background-color: black;
overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
a,
li {
margin: 0;
padding: 0;
}

#container {
width: 100vw;
height: 100vh;
position: relative;
float: left;
opacity: 0;
}

#c-container,
#c2-container {
width: 100vw;
height: 80vh;
position: absolute;
top: 0;
left: 0;
}

canvas {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
</style>

JS код - то же самое - и в страницу, и в footer.php -

<script type='text/javascript>
$(window).bind('load', function () {
const raf = function (entry) {
window.requestAnimationFrame(entry);
};
const random = function (min, max) {
max = max + 1;
return Math.floor(Math.random() * (max - min) + min);
}
var app = {
init: function () {
this.cacheDOM();
this.style();
},
cacheDOM: function () {
this.container = $('#container');
this.images = $('img');

this.mouseX = null;
this.mouseY = null;
},
style: function () {
this.images.imagesLoaded(function () {
$(window).resize(function initial() {
TweenMax.set(app.container, {
opacity: 1
});
return initial;
}());
});
},
cursorEvents: function (e) {
app.mouseX = e.clientX;
app.mouseY = e.clientY;
}
}

app.init();

var cContainer = $('#c-container'),
c = document.getElementById('c'),
c2Container = $('#c2-container'),
c2 = document.getElementById('c2'),
cx = c.getContext('2d'),
c2x = c2.getContext('2d'),
particleIndex = 0,
particles = {},
particleNum = 1,
particlesLoaded = false,
Particle,
Particle2,
canvas,
canvas2;

c.width = $('#c').outerWidth();
c.height = $('#c').outerHeight();

c2.width = $('#c2').outerWidth();
c2.height = $('#c2').outerHeight();

//INITIAL CANVAS DRAW
cx.fillStyle = 'rgba(0,0,0,1)';
cx.fillRect(0, 0, c.width, c.height);
c2x.fillStyle = 'rgba(0,0,0,1)';
c2x.fillRect(0, 0, c2.width, c2.height);

function particleFactory(thisCanvas, thisContext, thisParticleName, thisCanvasFunction) {

var particleIndex = 0,
particles = {},
particleNum = 2,
particlesLoaded = false;

thisParticleName = function () {
this.r = 8;
this.rStart = this.r;
this.rIncrement = this.r * -0.01;
this.x = thisCanvas.width / 2;
this.y = thisCanvas.height / 2;

this.vxIsNegative = random(1,2);

this.originTriggered = false;
this.vx = this.vxIsNegative === 1 ? random(0,50) * -0.1 : random(0,50) * 0.1;
this.vxMult = random(10,20) * 0.1;
this.vy = random(-10, 10);
this.vyMult = random(2,6) * -0.1;
this.opacityLimit = 1;
this.opacity = 1;
this.opacityIncrement = 0.05;
this.opacityReversing = false;
this.gravity = 1;
this.framerate = 0;
this.framerateCounter = this.framerate;
this.counter = 0;
particleIndex++;
particles[particleIndex] = this;
this.id = particleIndex;
this.life = 0;
this.maxLife = random(0, 100);
this.hue = random(30, 60);
this.light = random(50, 100);
this.color = `hsla(${this.hue},100%,${this.light}%,${this.opacity})`;

this.bounced = false;

this.duration = 60;
this.durationTotal = this.duration + this.opacityLimit * 10;
this.durationCounter = 0;
}

thisParticleName.prototype.draw = function () {

if ((!this.originTriggered) && (app.mouseX != null)) {
this.originTriggered = true;
this.x = app.mouseX;
this.y = app.mouseY;
}
this.color = `hsla(${this.hue},100%,${this.light}%,${this.opacity})`;
thisContext.fillStyle = this.color;
thisContext.beginPath();
thisContext.arc(this.x, this.y, this.r, 0, 2 * Math.PI);
thisContext.fill();

//START DRAW OPERATION
this.r += this.rIncrement;
this.x += this.vx;
this.y += this.vy;
this.durationCounter++;
if (this.vx === 0) {
this.vx++;
}
if (this.vxIsNegative === 1) {
this.vx
}
if (this.vy === 0) {
this.vy++;
}
if (this.y > thisCanvas.height - this.rStart) {
if (!this.bounced) {
this.vx *= this.vxMult;
} else {
this.vx *= 0.9;
}
this.bounced = true;
this.vy *= this.vyMult;
this.y = thisCanvas.height - this.rStart;
}
this.vy += this.gravity;
if ((this.r <= 0)) {
delete particles[this.id];
}
this.life++;
//END DRAW OPERATION
}

thisCanvasFunction = function () {
thisContext.globalCompositeOperation = 'source-over';
thisContext.fillStyle = 'rgba(0,0,0,1)';
thisContext.fillRect(0, 0, thisCanvas.width, thisCanvas.height);
if (!particlesLoaded) {
for (var i = 0; i < particleNum; i++) {
new thisParticleName();
}
}
thisContext.globalCompositeOperation = 'lighter';
for (var i in particles) {
particles[i].draw();
}
}
setInterval(thisCanvasFunction, 15);
}

$(window).resize(function initial() {
window.addEventListener('mousemove', app.cursorEvents, false);

c.width = $('#c').outerWidth();
c.height = $('#c').outerHeight();

c2.width = $('#c2').outerWidth();
c2.height = $('#c2').outerHeight();

return initial;
}());

particleFactory(c, cx, Particle, canvas);
particleFactory(c2, c2x, Particle2, canvas2);

TweenMax.set(c2Container, {
transformOrigin: 'center bottom',
scaleY: -1,
opacity: 1
});

TweenMax.set(c2, {
filter: 'blur(10px)'
});
});
</script>

Подключил
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TimelineMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://npmcdn.com/babel-core@5.8.38/browser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.1.1/imagesloaded.pkgd.min.js"></script>

Ничего не помогает. Что я делаю не так?

Замечание модератора:
Эта тема была закрыта автоматически ввиду отсутствия активности в ней на протяжении 100+ дней.
Если Вы считаете ее актуальной и хотите оставить сообщение, то воспользуйтесь кнопкой
или обратитесь к любому из модераторов.
0
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
Открыть тему
Тема закрыта
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0


Свернуть

> Похожие темы

  Тема Ответов Автор Просмотров Последний ответ
Открытая тема (нет новых ответов) Крауд-маркетинг который работает | Эффективные Ру-ссылки
1 Azyuka 957 13.2.2024, 19:36
автор: tascha56
Открытая тема (нет новых ответов) Скрипт поисковика видео StrongTube
3 3josoft 1561 14.8.2023, 14:45
автор: 3josoft
Открытая тема (нет новых ответов) Скрипт приема платежей p2p с карты на карту card2card
Скрипт приема платежей p2p с карты на карту card2card
15 zladey1986 7780 26.3.2023, 8:54
автор: Palundra
Открытая тема (нет новых ответов) Продам скрипт перевода постов и комментариев
4 Tutich 749 19.1.2023, 17:23
автор: Tutich
Открытая тема (нет новых ответов) Битрикс скрипт нативной установки
3 Nemo 2439 20.11.2022, 10:09
автор: Webmaster24


 



RSS Текстовая версия Сейчас: 28.3.2024, 21:39
Дизайн