Z
Z
z_u_l2018-12-18 18:24:15
JavaScript
z_u_l, 2018-12-18 18:24:15

Why does the custom description slide down when the map is initialized?

When loading the map, you can see the open label description, if you close it by clicking on the map, and then open it by clicking on the balloon image, then the label description will move higher (as it should). Why does the label's custom description appear lower during initialization? How can this be corrected?
Link to example

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lloydbanks, 2018-12-18
@lloydbanks

Why does the label's custom description appear lower during initialization?

Because when initialized at the moment the method is called, applyElementOffset
.mapBalloonit does not contain content and is 60px in height (empty container + padding 30px above and below)
.mapBalloon-arrowalso with zero height, from which 12 is subtracted.
Total 60 + - 12 = -48px
this._$element.css({
  left: -(this._$element[0].offsetWidth / 2),
  top: -(this._$element[0].offsetHeight // 60
  + this._$element.find('.mapBalloon-arrow')[0].offsetHeight - 12 // -12
  // top: -48px
)});

When clicked, the balloon already contains text, due to which the height of the balloon is 207px
Total 207 + - 12 = -195px
Call applyElementOffsetafter you fill the balloon with content

S
Sergey Dolgopolov, 2018-12-19
@Sergeyopt

The author, you were given a sensible answer, why didn’t you mark it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question