Skip to content

Commit 9eb45d2

Browse files
author
Sergey Gromskiy
committed
1 parent ad25218 commit 9eb45d2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

16 - Mouse Move Shadow/index-start.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ <h1 contenteditable>🔥WOAH!</h1>
3131
</style>
3232

3333
<script>
34+
(function(){
35+
let hero = document.querySelector('.hero');
36+
let text = hero.querySelector('h1');
37+
38+
function drowShadow(e){
39+
let { offsetWidth: width, offsetHeight: height } = hero;
40+
let { offsetX: x, offsetY: y } = e;
41+
if(this !== e.target){
42+
x = x + e.target.offsetLeft;
43+
y = y + e.target.offsetTop;
44+
}
45+
let sizeX = (width / 2 - x) / 10;
46+
let sizeY = (height / 2 - y) / 10;
47+
48+
text.style.textShadow = `${sizeX}px ${sizeY}px 0px rgba(0, 0, 0, 0.5), ${-sizeX}px ${-sizeY}px 0px rgba(200, 0, 0, 0.5)`;
49+
50+
}
51+
52+
hero.addEventListener('mousemove', drowShadow);
53+
})();
3454
</script>
3555
</body>
3656
</html>

17 - Sort Without Articles/index-START.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@
4343
<ul id="bands"></ul>
4444

4545
<script>
46-
const bands = ['The Plot in You', 'The Devil Wears Prada', 'Pierce the Veil', 'Norma Jean', 'The Bled', 'Say Anything', 'The Midway State', 'We Came as Romans', 'Counterparts', 'Oh, Sleeper', 'A Skylit Drive', 'Anywhere But Here', 'An Old Dog'];
46+
47+
const bands = ['The Plot in You', 'The Devil Wears Prada', 'Pierce the Veil', 'Norma Jean', 'The Bled', 'Say Anything', 'The Midway State', 'We Came as Romans', 'Counterparts', 'Oh, Sleeper', 'A Skylit Drive', 'Anywhere But Here', 'An Old Dog'];
48+
function trimArticle(name) {
49+
return name.replace(/^(a |an |the )/i, '');
50+
}
51+
const sortedBands = bands.sort((a, b) => (trimArticle(a) > trimArticle(b)) ? 1 : -1);
52+
const list = document.querySelector('#bands');
53+
list.innerHTML = sortedBands.map(item => `<li>${item}</li>`).join('');
4754

4855

4956
</script>

0 commit comments

Comments
 (0)