Skip to content

Commit

Permalink
feat(bulletchatting-demo): move generating bulletchattings below even…
Browse files Browse the repository at this point in the history
…t binding
  • Loading branch information
DIYgod committed Aug 21, 2019
1 parent 15a1c8b commit d6fe27d
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions demos/bulletchatting-proposal-demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,7 @@ const video = document.querySelector('video');
list.bulletchattingplaystate = 'paused';
list.area = 40;
list.bulletchattingduration = 6000;
const texts = ['He sits no sure that sits too high 🤧', 'He that respects not is not respected', 'So said, so done', 'Haste makes waste 🥵', 'Better be envied than pitied', 'So the world wags', 'One can not be in two places at once', 'No weal without woe']

// generate bulletchattings
const duration = 146;
const bulletchattings = [];
for (let i = 0; i < duration * 7; i++) {
bulletchattings.push({
text: texts[parseInt(Math.random() * texts.length)],
time: Math.random() * duration,
mode: 'scroll',
});
}
for (let i = 0; i < duration * 0.5; i++) {
bulletchattings.push({
text: texts[parseInt(Math.random() * texts.length)],
time: Math.random() * duration,
mode: 'top',
});
}
for (let i = 0; i < duration * 0.5; i++) {
bulletchattings.push({
text: texts[parseInt(Math.random() * texts.length)],
time: Math.random() * duration,
mode: 'bottom',
});
}
bulletchattings.sort((a, b) => a.time - b.time);
const texts = ['He sits no sure that sits too high 🤧', 'He that respects not is not respected', 'So said, so done', 'Haste makes waste 🥵', 'Better be envied than pitied', 'So the world wags', 'One can not be in two places at once', 'No weal without woe'];

window.addbulletchatting = (text, mode, fontSize, duration, delay) => {
const bulletchatting = document.createElement('bullet-chatting');
Expand Down Expand Up @@ -81,4 +55,30 @@ video.addEventListener('seeking', () => {
break;
}
}
});
});

// generate bulletchattings
const duration = 146;
const bulletchattings = [];
for (let i = 0; i < duration * 7; i++) {
bulletchattings.push({
text: texts[parseInt(Math.random() * texts.length)],
time: Math.random() * duration,
mode: 'scroll',
});
}
for (let i = 0; i < duration * 0.5; i++) {
bulletchattings.push({
text: texts[parseInt(Math.random() * texts.length)],
time: Math.random() * duration,
mode: 'top',
});
}
for (let i = 0; i < duration * 0.5; i++) {
bulletchattings.push({
text: texts[parseInt(Math.random() * texts.length)],
time: Math.random() * duration,
mode: 'bottom',
});
}
bulletchattings.sort((a, b) => a.time - b.time);

0 comments on commit d6fe27d

Please sign in to comment.