Skip to content

Commit fbc9080

Browse files
committed
1.0.3, improved zoom
1 parent 2e89a9c commit fbc9080

5 files changed

Lines changed: 34 additions & 20 deletions

File tree

example/codeKeyframes.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/codeKeyframes.js

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/codeKeyframes.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/app/main.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function CodeKeyframes(args){
1212
this.skipLength = 1
1313
this.zoom = 30
1414
this.nudging = false
15+
this.nudgeMult = 1
1516

1617
this.sequence = []
1718
this.sequenceCursor = 0
@@ -97,7 +98,9 @@ function CodeKeyframes(args){
9798
this._code.value = JSON.stringify(keyframes)
9899
}
99100

100-
this._editor.onkeydown = (e) =>{
101+
102+
103+
document.addEventListener('keydown', (e) => {
101104

102105
console.log(e.which)
103106

@@ -127,12 +130,14 @@ function CodeKeyframes(args){
127130
// up
128131
38:()=>{
129132
this.zoom += 0.5
133+
this.nudgeMult = this.nudgeMult * .985
130134
this.wavesurfer.zoom(this.zoom)
131135
},
132136

133137
// down
134138
40:()=>{
135139
this.zoom -= 0.5
140+
this.nudgeMult = this.nudgeMult * 1.025
136141
this.wavesurfer.zoom(this.zoom)
137142
},
138143

@@ -169,9 +174,6 @@ function CodeKeyframes(args){
169174

170175
// space
171176
32:()=>{
172-
173-
console.log("PLAYPAUSE")
174-
175177
this.wavesurfer.playPause()
176178
this._code.classList.remove('error')
177179
},
@@ -217,9 +219,9 @@ function CodeKeyframes(args){
217219
keycodes[e.which]()
218220
}
219221

220-
}
222+
})
221223

222-
this._editor.onkeyup = (e) =>{
224+
document.addEventListener('keyup', (e) =>{
223225

224226
var keycodes = {
225227
// shift
@@ -236,7 +238,7 @@ function CodeKeyframes(args){
236238
if( keycodes[e.which] ){
237239
keycodes[e.which]()
238240
}
239-
}
241+
})
240242

241243

242244
/*
@@ -341,7 +343,11 @@ function CodeKeyframes(args){
341343
this.nudgeActiveRegion = (direction) => {
342344

343345
region = this.activeRegion
344-
nudgeAmount = (direction == 'left') ? -.1 : .1
346+
347+
nudgeAmount = .1 * this.nudgeMult
348+
if( direction == 'left' ) nudgeAmount = nudgeAmount * -1
349+
350+
// nudgeAmount = (direction == 'left') ? -.1 : .1
345351

346352
this.activeRegion = this.wavesurfer.addRegion({
347353
start: region.start + nudgeAmount,

src/scss/style.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@
5252
}
5353

5454
region.wavesurfer-region{
55-
background-color: #fff!important;
55+
background-color: transparent!important;
56+
border-left:2px solid #fff;
5657
cursor: pointer;
58+
5759
&:after{
5860
content:'';
5961
display: block;
@@ -70,7 +72,7 @@
7072
}
7173

7274
&.active{
73-
background-color: violet!important;
75+
border-left:2px solid violet;
7476
&:after{
7577
border-color: transparent transparent transparent violet;
7678
}

0 commit comments

Comments
 (0)