-
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added container elements, volume to array (#513) and fixed scoping bugs
- Loading branch information
1 parent
8e6d626
commit 063c37d
Showing
30 changed files
with
701 additions
and
157 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Play Button | ||
|
||
There are 4 different levels for a play button. To scope a play button to the type of audio you wish to play, you can apply special attributes to the element. | ||
|
||
The play button element responds to a `click` event on desktop browsers or a `touchstart` event on mobile browsers. | ||
|
||
### Global Play Button | ||
|
||
### Collection Play Button | ||
|
||
### Audio Play Button | ||
|
||
### Audio in Collection Play Button |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Volume Up Element | ||
|
||
### Overview | ||
The volume up element increases the global volume level of AmplitudeJS by the amount defined. This amount is an integer value between `0` and `100` with `0` being muted, and `100` as maximum. As a safe default, the increment value is set to `5` which means that on click/touch the volume will increment 5%. | ||
|
||
### Creating a Volume Up Element | ||
|
||
### Related Configuration Variables | ||
Default `5` | ||
|
||
`config.volume.increment` | ||
|
||
On init: | ||
Amplitude.init({ | ||
volume: { | ||
increment: 5 | ||
} | ||
}) | ||
|
||
### Notes | ||
Does not work on iOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Upgrading from 5.x to 6.0 | ||
|
||
There are a variety of breaking changes as we move AmplitudeJS into a more professional audio library. The features added aim to improve developer experience while minimizing breaking changes. I'll try to cover all scenarios in this document. If there is anything I've missed, please let me know. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { AudioContainerElement } from "./ContainerElements/AudioContainerElement"; | ||
import { CollectionAudioContainerElement } from "./ContainerElements/CollectionAudioContainerElement"; | ||
|
||
export class ContainerElement{ | ||
static containerElementQuery = '.amplitude-audio-container'; | ||
|
||
setActiveContainers( direct ){ | ||
this.#setActiveAudioContainers(); | ||
this.#setActiveCollectionAudioContainers( direct ); | ||
} | ||
|
||
#setActiveAudioContainers(){ | ||
let audioContainerElements = new AudioContainerElement(); | ||
audioContainerElements.setActive(); | ||
} | ||
|
||
#setActiveCollectionAudioContainers( direct ){ | ||
let collectionAudioContainerElements = new CollectionAudioContainerElement( direct ); | ||
collectionAudioContainerElements.setActive(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { config } from "@/config"; | ||
import { ConfigState } from "@/services/ConfigState"; | ||
|
||
export class AudioContainerElement { | ||
static audioContainerElementQuery = '.amplitude-audio-container[data-amplitude-audio-index]:not([data-amplitude-collection-key])'; | ||
|
||
#elements; | ||
#activeIndex; | ||
|
||
setActive(){ | ||
if( ConfigState.getScope() == 'audio' ){ | ||
this.#findElements(); | ||
this.#resetElements(); | ||
this.#getActiveIndex(); | ||
this.#setActiveContainerElements(); | ||
} | ||
} | ||
|
||
#findElements(){ | ||
this.#elements = document.querySelectorAll( AudioContainerElement.audioContainerElementQuery ); | ||
} | ||
|
||
#resetElements(){ | ||
this.#elements.forEach( function( element ){ | ||
element.classList.remove('amplitude-active-audio-container'); | ||
}); | ||
} | ||
|
||
#getActiveIndex(){ | ||
this.#activeIndex = config.active_index; | ||
} | ||
|
||
#setActiveContainerElements(){ | ||
let activeContainerElements = document.querySelectorAll('.amplitude-audio-container[data-amplitude-audio-index="'+this.#activeIndex+'"]:not([data-amplitude-collection-key])'); | ||
|
||
activeContainerElements.forEach( function( element ){ | ||
element.classList.add("amplitude-active-audio-container"); | ||
}); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/elements/ContainerElements/CollectionAudioContainerElement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { config } from "@/config"; | ||
import { ConfigState } from "@/services/ConfigState"; | ||
|
||
export class CollectionAudioContainerElement { | ||
static collectionAudioContainerElementQuery = '.amplitude-audio-container[data-amplitude-audio-index][data-amplitude-collection-key]'; | ||
|
||
#direct; | ||
#elements; | ||
#activeIndex; | ||
#activeCollection; | ||
|
||
constructor( direct ){ | ||
this.#direct = direct; | ||
} | ||
|
||
setActive(){ | ||
if( ConfigState.getScope() == 'collection' ){ | ||
this.#findElements(); | ||
this.#resetElements(); | ||
this.#getActiveIndex(); | ||
this.#setActiveContainerElements(); | ||
} | ||
} | ||
|
||
#findElements(){ | ||
this.#elements = document.querySelectorAll( CollectionAudioContainerElement.collectionAudioContainerElementQuery ); | ||
} | ||
|
||
#resetElements(){ | ||
this.#elements.forEach( function( element ){ | ||
element.classList.remove('amplitude-active-audio-container'); | ||
}); | ||
} | ||
|
||
#getActiveIndex(){ | ||
this.#activeCollection = ConfigState.getActiveCollection(); | ||
|
||
if( this.#direct ){ | ||
this.#activeIndex = config.collections[ this.#activeCollection ].active_index; | ||
}else{ | ||
if( ConfigState.isCollectionShuffled( this.#activeCollection ) ){ | ||
this.#activeIndex = config.collections[ this.#activeCollection ].shuffle_list[ | ||
config.collections[ this.#activeCollection ].active_index | ||
].index; | ||
}else{ | ||
this.#activeIndex = config.collections[ this.#activeCollection ].active_index; | ||
} | ||
} | ||
} | ||
|
||
#setActiveContainerElements(){ | ||
let activeContainerElements = document.querySelectorAll('.amplitude-audio-container[data-amplitude-audio-index="'+this.#activeIndex+'"][data-amplitude-collection-key="'+this.#activeCollection+'"]'); | ||
activeContainerElements.forEach( function( element ){ | ||
element.classList.add("amplitude-active-audio-container"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.