Skip to content

Commit

Permalink
Prepare version 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Apr 25, 2020
1 parent 4d5a974 commit 2687029
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 24 deletions.
4 changes: 1 addition & 3 deletions docs/.vuepress/plugins/version-mixin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const pkg = require('../../../package');

export default {
mounted () {
setTimeout(() => {
const titleElt = document.querySelector('.site-name');
titleElt.innerHTML+= ` <small class="md-badge md-primary md-square md-theme-default">${pkg.version}</small>`;
titleElt.innerHTML+= ` <small class="md-badge md-primary md-square md-theme-default">4.0.0</small>`;
});
}
}
4 changes: 2 additions & 2 deletions docs/plugins/writing-a-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class PhotoSphereViewerCustomPlugin extends AbstractPlugin {
}

destroy() {
// do you cleanup logic here
// do your cleanup logic here

super.destroy();
}
Expand Down Expand Up @@ -134,7 +134,7 @@ export class CustomButton extends AbstractButton {
}

destroy() {
// do you cleanup logic here
// do your cleanup logic here

super.destroy();
}
Expand Down
14 changes: 14 additions & 0 deletions src/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,13 @@ export class Viewer extends EventEmitter {
return;
}

/**
* @event get-rotate-position
* @memberof PSV
* @param {Position} position
* @returns {Position}
* @summary Called to alter the target position of a rotation
*/
const cleanPosition = this.change(CHANGE_EVENTS.GET_ROTATE_POSITION, this.dataHelper.cleanPosition(position));

if (this.prop.position.longitude !== cleanPosition.longitude || this.prop.position.latitude !== cleanPosition.latitude) {
Expand Down Expand Up @@ -739,6 +746,13 @@ export class Viewer extends EventEmitter {

// clean/filter position and compute duration
if (positionProvided) {
/**
* @event get-animate-position
* @memberof PSV
* @param {Position} position
* @returns {Position}
* @summary Called to alter the target position of an animation
*/
const cleanPosition = this.change(CHANGE_EVENTS.GET_ANIMATE_POSITION, this.dataHelper.cleanPosition(options));

// longitude offset for shortest arc
Expand Down
15 changes: 13 additions & 2 deletions src/components/Overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export class Overlay extends AbstractComponent {
super.destroy();
}

/**
* @override
* @param {string} [id]
*/
isVisible(id) {
return this.prop.visible && (!id || !this.prop.contentId || this.prop.contentId === id);
}

/**
* @override
*/
Expand Down Expand Up @@ -120,7 +128,7 @@ export class Overlay extends AbstractComponent {
* @event show-overlay
* @memberof PSV
* @summary Trigered when the overlay is shown
* @param {string} id
* @param {string} [id]
*/
this.psv.trigger(EVENTS.SHOW_OVERLAY, config.id);
}
Expand All @@ -132,6 +140,8 @@ export class Overlay extends AbstractComponent {
*/
hide(id) {
if (this.isVisible() && (!id || !this.prop.contentId || this.prop.contentId === id)) {
const contentId = this.prop.contentId;

super.hide();

this.prop.contentId = undefined;
Expand All @@ -140,8 +150,9 @@ export class Overlay extends AbstractComponent {
* @event hide-overlay
* @memberof PSV
* @summary Trigered when the overlay is hidden
* @param {string} [id]
*/
this.psv.trigger(EVENTS.HIDE_OVERLAY);
this.psv.trigger(EVENTS.HIDE_OVERLAY, contentId);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/components/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class Panel extends AbstractComponent {
* @event open-panel
* @memberof PSV
* @summary Triggered when the panel is opened
* @param {string} id
* @param {string} [id]
*/
this.psv.trigger(EVENTS.OPEN_PANEL, config.id);
}
Expand All @@ -171,6 +171,8 @@ export class Panel extends AbstractComponent {
*/
hide(id) {
if (this.isVisible(id)) {
const contentId = this.prop.contentId;

this.prop.visible = false;
this.prop.contentId = undefined;

Expand All @@ -186,8 +188,9 @@ export class Panel extends AbstractComponent {
* @event close-panel
* @memberof PSV
* @summary Trigered when the panel is closed
* @param {string} [id]
*/
this.psv.trigger(EVENTS.CLOSE_PANEL);
this.psv.trigger(EVENTS.CLOSE_PANEL, contentId);
}
}

Expand Down
26 changes: 15 additions & 11 deletions src/components/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ const TOP_MAP = { 0: 'top', 0.5: 'center', 1: 'bottom' };
const STATE = { NONE: 0, SHOWING: 1, HIDING: 2, READY: 3 };

/**
* @typedef {Object} Tooltip.Config
* @summary Object defining the tooltip configuration
* @property {string} content - HTML content of the tooltip
* @typedef {Object} PSV.components.Tooltip.Position
* @summary Object defining the tooltip position
* @property {number} top - Position of the tip of the arrow of the tooltip, in pixels
* @property {number} left - Position of the tip of the arrow of the tooltip, in pixels
* @property {string|string[]} [position='top center'] - Tooltip position toward it's arrow tip.
* Accepted values are combinations of `top`, `center`, `bottom` and `left`, `center`, `right`
* @property {string} [className] - Additional CSS class added to the tooltip
* @property {Object} [box] - Used when displaying a tooltip on a marker
* @property {number} [box.width=0]
* @property {number} [box.height=0]
*/

/**
* @typedef {PSV.components.Tooltip.Position} PSV.components.Tooltip.Config
* @summary Object defining the tooltip configuration
* @property {string} content - HTML content of the tooltip
* @property {string} [className] - Additional CSS class added to the tooltip
* @property {*} [data] - Userdata associated to the tooltip
*/

Expand Down Expand Up @@ -117,14 +122,14 @@ export class Tooltip extends AbstractComponent {
}

/**
* @summary Displays a tooltip on the viewer
* @param {Tooltip.Config} config
* @summary Displays the tooltip on the viewer
* Do not call this method directly, use {@link PSV.services.TooltipRenderer} instead.
* @param {PSV.components.Tooltip.Config} config
*
* @fires PSV.show-tooltip
* @throws {PSV.PSVError} when the configuration is incorrect
*
* @example
* viewer.showTooltip({ content: 'Hello world', top: 200, left: 450, position: 'center bottom'})
* @package
*/
show(config) {
if (this.prop.state !== STATE.NONE) {
Expand Down Expand Up @@ -160,7 +165,7 @@ export class Tooltip extends AbstractComponent {

/**
* @summary Moves the tooltip to a new position
* @param {Tooltip.Config} config
* @param {PSV.components.Tooltip.Position} config
*
* @throws {PSV.PSVError} when the configuration is incorrect
*/
Expand Down Expand Up @@ -256,9 +261,8 @@ export class Tooltip extends AbstractComponent {
* @memberof PSV
* @summary Trigered when the tooltip is hidden
* @param {*} Data associated to this tooltip
* @param {PSV.components.Tooltip} Instance of the tooltip
*/
this.psv.trigger(EVENTS.HIDE_TOOLTIP, this.prop.data, this);
this.psv.trigger(EVENTS.HIDE_TOOLTIP, this.prop.data);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export {
* @property {number} viewerY - position in the viewer
* @property {number} longitude - position in spherical coordinates
* @property {number} latitude - position in spherical coordinates
* @property {number} textureX - position on the texture
* @property {number} textureY - position on the texture
* @property {number} [textureX] - position on the texture, undefined for cubemaps
* @property {number} [textureY] - position on the texture, undefined for cubemaps
* @property {PSV.plugins.MarkersPlugin.Marker} [marker] - clicked marker
*/

Expand Down
10 changes: 8 additions & 2 deletions src/services/TooltipRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ export class TooltipRenderer extends AbstractService {
}

/**
* @summary Displays a new tooltip
* @param {Tooltip.Config} config
* @summary Displays a tooltip on the viewer
* @param {PSV.components.Tooltip.Config} config
* @returns {PSV.components.Tooltip}
*
* @fires PSV.show-tooltip
* @throws {PSV.PSVError} when the configuration is incorrect
*
* @example
* viewer.tooltip.create({ content: 'Hello world', top: 200, left: 450, position: 'center bottom'})
*/
create(config) {
const tooltip = new Tooltip(this.psv, this.size);
Expand Down

0 comments on commit 2687029

Please sign in to comment.