claviska/jquery-minicolors

Top position is off when using 'position: top' with swatches

Open

#236 ouverte le 23 nov. 2017

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)JavaScript (322 forks)batch import
BugHelp Wanted

Métriques du dépôt

Stars
 (955 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

When you use minicolors with swatches, combined with position: 'top left' or position:'top right', the colorpicker panel is positioned incorrectly, it overlays the input box. minicolors1 minicolors2

I've made the following fix in jquery.minicolor.js, starting at line 212:

    // Swatches
    if(settings.swatches && settings.swatches.length !== 0) {
      if (/top/.test(settings.position)) {
         var nrRows = Math.ceil(settings.swatches.length / 7);
         panel.css('top', (nrRows == 1 ? -182 : -204)+'px');
      }
      panel.addClass('minicolors-with-swatches');
      ....

Variable nrRows contains the number of rows of swatches (either 1 or 2), and the top position is changed accordingly. This fixes it for me. Hopefully you can apply this (or a similar) fix. Thanks, keep up the good work!

Guide contributeur