Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature for issue #244: Attempt at configuring the long press time #245

Merged
merged 11 commits into from
Jan 25, 2020
9 changes: 9 additions & 0 deletions docs/timeline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,15 @@ <h2 id="Configuration_Options">Configuration Options</h2>
<td>A map with i18n locales. See section <a href="#Localization">Localization</a> for more information.</td>
</tr>

<tr>
<td>longSelectPressTime</td>
<td>number</td>
<td><code>251</code></td>
<td>
The minimal press time in ms for an event to be considered a (long) press.
</td>
</tr>

<tr>
<td>moment</td>
<td>function</td>
Expand Down
11 changes: 8 additions & 3 deletions lib/timeline/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ class Core {
const fields = [
'width', 'height', 'minHeight', 'maxHeight', 'autoResize',
'start', 'end', 'clickToUse', 'dataAttributes', 'hiddenDates',
'locale', 'locales', 'moment', 'preferZoom', 'rtl', 'zoomKey', 'horizontalScroll', 'verticalScroll'
'locale', 'locales', 'moment', 'preferZoom', 'rtl', 'zoomKey',
'horizontalScroll', 'verticalScroll', 'longSelectPressTime'
];
util.selectiveExtend(fields, this.options, options);

util.selectiveExtend(fields, this.options, options);
this.dom.rollingModeBtn.style.visibility = 'hidden';

if (this.options.rtl) {
Expand Down Expand Up @@ -1050,6 +1050,11 @@ class Core {
direction: contentsOverflow ? Hammer.DIRECTION_ALL : Hammer.DIRECTION_HORIZONTAL
});

// set the long press time
this.hammer.get('press').set({
time: this.options.longSelectPressTime
});

// redraw all components
this.components.forEach(component => {
resized = component.redraw() || resized;
Expand Down
1 change: 1 addition & 0 deletions lib/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class Timeline extends Core {
const me = this;
this.defaultOptions = {
autoResize: true,
longSelectPressTime: 251,
orientation: {
axis: 'bottom', // axis orientation: 'bottom', 'top', or 'both'
item: 'bottom' // not relevant
Expand Down
5 changes: 4 additions & 1 deletion lib/timeline/component/ItemSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ItemSet extends Component {

selectable: true,
multiselect: false,
longSelectPressTime: 251,
itemsAlwaysDraggable: {
item: false,
range: false,
Expand Down Expand Up @@ -392,7 +393,7 @@ class ItemSet extends Component {
// copy all options that we know
const fields = [
'type', 'rtl', 'align', 'order', 'stack', 'stackSubgroups', 'selectable', 'multiselect', 'sequentialSelection',
'multiselectPerGroup', 'groupOrder', 'dataAttributes', 'template', 'groupTemplate', 'visibleFrameTemplate',
'multiselectPerGroup', 'longSelectPressTime', 'groupOrder', 'dataAttributes', 'template', 'groupTemplate', 'visibleFrameTemplate',
'hide', 'snap', 'groupOrderSwap', 'showTooltips', 'tooltip', 'tooltipOnItemUpdateTime', 'groupHeightMode', 'onTimeout'
];
util.selectiveExtend(fields, this.options, options);
Expand Down Expand Up @@ -870,6 +871,8 @@ class ItemSet extends Component {
this.dom.axis.style.left = '0';
}

this.hammer.get('press').set({time: this.options.longSelectPressTime});

this.initialItemSetDrawn = true;
// check if this component is resized
resized = this._isResized() || resized;
Expand Down
2 changes: 2 additions & 0 deletions lib/timeline/optionsTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ let allOptions = {
__any__: {any},
__type__: {object}
},
longSelectPressTime: {number},
margin: {
axis: {number},
item: {
Expand Down Expand Up @@ -235,6 +236,7 @@ let configureOptions = {
height: '',
//hiddenDates: {object, array},
locale: '',
longSelectPressTime: 251,
margin: {
axis: [20, 0, 100, 1],
item: {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export interface TimelineOptions {
itemsAlwaysDraggable?: TimelineOptionsItemsAlwaysDraggableType;
locale?: string;
locales?: any; // TODO
longSelectPressTime?: number,
moment?: MomentConstructor;
margin?: TimelineOptionsMarginType;
max?: DateType;
Expand Down