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

Export DefaultPointMarker #419

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

thom4parisot
Copy link
Contributor

As of [email protected], the source code is not exposed so I have no way to access the DefaultPointMarker class.
This change is a way to keep it accessible,

I found it useful to extend an existing PointMarker instead of reimplementing all the logic.

If you think another path is more relevant, I'm happy to contribute the changes.

With [email protected], this is what I was doing to create a custom PointMarker:

// custom-marker.js
import DefaultPointMarker, { Line, Rect, Circle, Text } from 'peaks.js/src/default-point-marker.js'

export class PointMarker extends DefaultPointMarker {
  init (group) {
    super.init(group)

    this._line.strokeWidth(this._options.point.lineWidth || 1)

    console.log(this._options.view, this)
    if (this._options.view === 'zoomview' && this._handle) {
      const layerHeight = this._options.layer.getHeight()

      this._handle.width(20)
      this._handle.x(-10 - 4 + 0.5) // half a side - side rotation + half pixel
      this._handle.y(layerHeight - this._handle.height() + 9.5 + 0.5)
      this._handle.cornerRadius([20, 0, 20, 20])
      this._handle.rotate(-45)
    }
  }
}
// app.js
import { init } from 'peaks.js';
import { PointMarker } from './custom-markers.js'
import defaultOptions, {markerOptions} from './options.js'

init({
  ...defaultOptions,
  mediaElement: this.$refs.mainTrack,
  dataUri: {
    arraybuffer: this.$props.dataFile
  },
  containers: {
    overview: this.$refs.overview,
    zoomview: this.$refs.zoomview
  },
  createPointMarker: (options) => new PointMarker({
    ...markerOptions,
    fontSize: 14,
    fontStyle: 'bold'
  }),
}, onWaveformLoaded))

@thom4parisot thom4parisot changed the title Enable Export DefaultPointMarker Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant