-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a1b6c57
commit c82b122
Showing
21 changed files
with
365 additions
and
173 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Backbone from 'backbone'; | ||
import Adapt from 'core/js/adapt'; | ||
import ShadowView from './views/ShadowView'; | ||
|
||
class Shadow extends Backbone.Controller { | ||
|
||
initialize() { | ||
this.listenTo(Adapt, { | ||
'adapt:start': this.onAdaptStart | ||
}); | ||
} | ||
|
||
onAdaptStart() { | ||
this._shadowView = new ShadowView(); | ||
this._shadowView.$el.prependTo('body'); | ||
} | ||
|
||
get isOpen() { | ||
return this._shadowView?.isOpen ?? false; | ||
} | ||
|
||
async show() { | ||
return this._shadowView?.showShadow(); | ||
} | ||
|
||
async hide() { | ||
return this._shadowView?.hideShadow(); | ||
} | ||
|
||
remove() { | ||
this._shadowView?.remove(); | ||
this._shadowView = null; | ||
} | ||
|
||
} | ||
|
||
export default new Shadow(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Adapt from 'core/js/adapt'; | ||
import Backbone from 'backbone'; | ||
import { transitionNextFrame, transitionsEnded } from '../transitions'; | ||
|
||
class ShadowView extends Backbone.View { | ||
|
||
className() { | ||
return 'shadow js-shadow u-display-none'; | ||
} | ||
|
||
attributes() { | ||
return { | ||
id: 'shadow' | ||
}; | ||
} | ||
|
||
initialize() { | ||
this._isOpen = false; | ||
this.disableAnimation = Adapt.config.get('_disableAnimation') ?? false; | ||
this.$el.toggleClass('disable-animation', Boolean(this.disableAnimation)); | ||
this.render(); | ||
} | ||
|
||
render() { | ||
const template = Handlebars.templates.shadow; | ||
this.$el.html(template({ _globals: Adapt.course.get('_globals') })); | ||
return this; | ||
} | ||
|
||
get isOpen() { | ||
return this._isOpen; | ||
} | ||
|
||
async showShadow() { | ||
this._isOpen = true; | ||
this.$el.addClass('anim-show-before'); | ||
await transitionNextFrame(); | ||
this.$el.removeClass('u-display-none'); | ||
await transitionNextFrame(); | ||
this.$el.addClass('anim-show-after'); | ||
await transitionsEnded(this.$el); | ||
} | ||
|
||
async hideShadow() { | ||
this._isOpen = false; | ||
this.$el.addClass('anim-hide-before'); | ||
await transitionNextFrame(); | ||
this.$el.addClass('anim-hide-after'); | ||
await transitionsEnded(this.$el); | ||
this.$el.addClass('u-display-none'); | ||
await transitionNextFrame(); | ||
this.$el.removeClass('anim-open-before anim-open-after anim-hide-before anim-hide-after'); | ||
} | ||
|
||
} | ||
|
||
export default ShadowView; |
Oops, something went wrong.