Minor updates to Doctests.

This commit is contained in:
Uwe Oestermeier 2019-07-12 14:50:30 +02:00
parent e1b5c45b52
commit 0e8c62eb4b
4 changed files with 24 additions and 5 deletions

15
dist/iwmlib.js vendored
View File

@ -2974,6 +2974,20 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
/** This interface allows scatters to delegate tap events to other objects. */
class ITapDelegate extends Interface {
/** This method must be defined by the delegate. It handles the tap event. */
tap(event) {
}
/** Tells the delegate that it should handle standard click events. */
handleClicks() {
}
}
/** /**
* A base class for scatter specific events. * A base class for scatter specific events.
* *
@ -7737,6 +7751,7 @@
window.IApp = IApp; window.IApp = IApp;
window.IInteractionMapperTarget = IInteractionMapperTarget; window.IInteractionMapperTarget = IInteractionMapperTarget;
window.IInteractionTarget = IInteractionTarget; window.IInteractionTarget = IInteractionTarget;
window.ITapDelegate = ITapDelegate;
window.Index = Index; window.Index = Index;
window.Inspect = Inspect; window.Inspect = Inspect;
window.Interaction = Interaction; window.Interaction = Interaction;

View File

@ -15,7 +15,7 @@ import {EventRecorder} from './events.js'
import {FrameContainer, FrameTarget} from './frames.js' import {FrameContainer, FrameTarget} from './frames.js'
import {Inspect} from './inspect.js' import {Inspect} from './inspect.js'
import {PointMap, InteractionPoints, Interaction, IInteractionTarget, InteractionDelta, InteractionMapper, InteractionDelegate, IInteractionMapperTarget} from './interaction.js' import {PointMap, InteractionPoints, Interaction, IInteractionTarget, InteractionDelta, InteractionMapper, InteractionDelegate, IInteractionMapperTarget} from './interaction.js'
import {ResizeEvent, DOMScatterContainer, AbstractScatter, DOMScatter, ScatterEvent, BaseEvent} from './scatter.js' import {ITapDelegate, ResizeEvent, DOMScatterContainer, AbstractScatter, DOMScatter, ScatterEvent, BaseEvent} from './scatter.js'
import {Cycle, Colors, Elements, Angle, Dates, Points, Polygon, Rect, Sets, Strings, isEmpty, getId, lerp, debounce, randomInt, randomFloat, LowPassFilter} from './utils.js' import {Cycle, Colors, Elements, Angle, Dates, Points, Polygon, Rect, Sets, Strings, isEmpty, getId, lerp, debounce, randomInt, randomFloat, LowPassFilter} from './utils.js'
import UITest from './uitest.js' import UITest from './uitest.js'
@ -54,6 +54,7 @@ window.FrameTarget = FrameTarget
window.IApp = IApp window.IApp = IApp
window.IInteractionMapperTarget = IInteractionMapperTarget window.IInteractionMapperTarget = IInteractionMapperTarget
window.IInteractionTarget = IInteractionTarget window.IInteractionTarget = IInteractionTarget
window.ITapDelegate = ITapDelegate
window.Index = Index window.Index = Index
window.Inspect = Inspect window.Inspect = Inspect
window.Interaction = Interaction window.Interaction = Interaction

View File

@ -76,6 +76,8 @@
<script class="doctest"> <script class="doctest">
Doctest.expect(ITapDelegate.implementedBy(CardWrapper), true)
const wrapper1 = new CardWrapper(demoCardWithOnClick) const wrapper1 = new CardWrapper(demoCardWithOnClick)
wrapper1.handleClicksAsTaps() wrapper1.handleClicksAsTaps()
@ -92,8 +94,8 @@
<h2> <h2>
Using Cards within Scatters Using Cards within Scatters
</h2> </h2>
<p>Cards can be used within scatters. Since the CardWrapper implements the TapDelegate protocol they can simply <p>Cards can be used within scatters. Since the <code>CardWrapper</code> implements the <code>ITapDelegate</code> protocol they can simply
be attached to a DOMScatter object. be attached to a DOMScatter object. See the <a href="../scatter.html">Scatter Doctest</a>.
</p> </p>
<div class="interactive grayBorder" style="position: relative;"> <div class="interactive grayBorder" style="position: relative;">
</div> </div>

View File

@ -90,7 +90,8 @@ elements under or nearby the event position and calls the click handler. Thus ge
can be disambiguated as moves, zooms. or taps. can be disambiguated as moves, zooms. or taps.
Note that on touch devices you can tap beside the object if you use an object that implements the ITapDelegate interface. Note that on touch devices you can tap beside the object if you use an object that implements the ITapDelegate interface.
An ITapDelegate allowes a distance that can be configured by allowClickDistance. The default value is 44px. An ITapDelegate allowes a distance that can be configured by allowClickDistance. The default value is 44px but here we
use 88px.
</p> </p>
<div id="contentExample" class="grayBorder interactive" style="position: relative; width: 100%; height: 280px;"> <div id="contentExample" class="grayBorder interactive" style="position: relative; width: 100%; height: 280px;">
@ -111,7 +112,7 @@ An ITapDelegate allowes a distance that can be configured by allowClickDistance.
let contentContainer = new DOMScatterContainer(contentExample) let contentContainer = new DOMScatterContainer(contentExample)
let tapDelegate = new CardWrapper(interactiveContent) let tapDelegate = new CardWrapper(interactiveContent, { allowClickDistance: 88})
new DOMScatter(interactiveContent, contentContainer, { new DOMScatter(interactiveContent, contentContainer, {
x: 44, x: 44,
y: 44, y: 44,