modal: add doubleTap option

This commit is contained in:
jean-emmanuel 2017-06-14 21:50:00 +02:00
parent 148a5ddce7
commit 9abd6c7678
3 changed files with 24 additions and 11 deletions

View file

@ -11,7 +11,7 @@ Sessions saved with this version will not be readable with older versions (old s
- add property inheritance between widgets with statements `@{parent.propertyName}`, `@{this.propertyName}` and `@{widgetID.propertyName}`
- containers: added `variables` options (arbitrary varibles to pass to children)
- panel: added full osc support (for sending/receiving tab changes)
- modal: changed style to fit popups' appearance; added `popupWidth` and `popupHeight` options; :warning: removed `tabs` option; added full osc support
- modal: changed style to fit popups' appearance; added `popupWidth` and `popupHeight` options; :warning: removed `tabs` option; added full osc support; added `doubleTap` option (makes it openable with double taps instead of single taps)
- strip: refactored widget using `panel` as base; added `stretch` and `spacing` option; now it's really cool
- sliders: added double tap support (resets the widget to its initial value)
- knob/fader: renamed `noPip` option to `pips` (inverted behaviour; backward compatible)
@ -19,6 +19,7 @@ Sessions saved with this version will not be readable with older versions (old s
- knob: compact design remake
- bug fixes
- sliders: fixed `spring` when `value` equals `0`
- modal: fixed osc values (was `True`/`False` instead of `1`/`0`)
- session
- the root panel is now saved as a special `panel` widget (which means it has savable options)
- custom module

View file

@ -65,7 +65,7 @@ Panels can contains tabs or widgets. These can be absolutely positioned and can
## Strip
Unidirectionnal panel with stretching capability. By default, children widgets that don't have an explicit `width`/`height` set will be shrinked to respect the sizes specified by others. Adding `flex:1;` to a children's `css` will give it the ability the fill the remaining space. Multiple children can have a `flex:x;` css property (`x` will ponderate their expansion).
Unidirectionnal panel with stretching capability. By default, children widgets that don't have an explicit `width`/`height` set will be shrinked to respect the sizes specified by others. Adding `flex:1;` to a children's `css` will give it the ability the fill the remaining space. Multiple children can have a `flex:x;` css property (`x` will ponderate their expansion).
```js
{
@ -103,11 +103,15 @@ Modals are buttons that turn into a centered popup panels when enabled. They can
}
```
#### `doubleTap`
- type: `boolean`
- default: `false`
- usage: set to `true` to make the modal require a double tap to open instead of a single tap
#### `popupWidth` / `popupHeight`
- type: `number|percentage`
- default: `100%`
- usage: sets the modal's size once opened.
- usage: sets the modal's size once opened
#### `options`
- see panel's [`options`](#panel)

View file

@ -1,5 +1,6 @@
var Panel = require('./panel'),
{icon} = require('../../utils')
{icon} = require('../../utils'),
doubletabreset = require('../mixins/double_tap_reset')
module.exports = class Modal extends Panel {
@ -22,6 +23,7 @@ module.exports = class Modal extends Panel {
_popup:'popup',
doubleTap: false,
popupWidth:'100%',
popupHeight:'100%',
@ -73,14 +75,20 @@ module.exports = class Modal extends Panel {
this.popup[0].style.setProperty('--height', height)
this.popup.find('.closer').on('fake-click',(e)=>{
this.setValue(false, {sync:true, send:true})
this.setValue(0, {sync:true, send:true})
})
this.light = $('<div class="light"></div>').appendTo(this.container)
this.light.on('fake-click',(e)=>{
if (e.button != 2)
this.setValue(!this.value, {sync:true, send:true})
})
if (this.getProp('doubleTap')) {
doubletabreset(this.light, ()=>{
this.setValue(1, {sync:true, send:true})
})
} else {
this.light.on('fake-click',(e)=>{
this.setValue(1, {sync:true, send:true})
})
}
this.parentScroll = [0,0]
this.value = false
@ -90,7 +98,7 @@ module.exports = class Modal extends Panel {
setValue(v, options={}) {
this.value = v ? true : false
this.value = v ? 1 : 0
if (!this.init) {
this.popup.find('.popup-title .popup-label').html(this.container.find('> .label span').html())