Code Monkey home page Code Monkey logo

x5-modal's Introduction

Hi ๐Ÿ‘‹, I'm Keagan

๐Ÿ”ญ Iโ€™m currently managing a team working on administration features for SafetyCulture

๐Ÿ’ฌ Ask me about strategy, management, frontend, and startups

๐Ÿ“ซ How to reach me: https://chisnall.io

โšก Fun fact I believe CSS is a programming language


xon52

Connect with me:

keagan.chisnall xon52 @xon5

x5-modal's People

Contributors

dependabot[bot] avatar xon52 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

x5-modal's Issues

Draggable Modals

Although I am still on the version 0.3.x of the Modals, I thought I'd suggest that you investigate adding 'draggability' to the modals. I found the following case in the Vuetify (which I use) hub: vuetifyjs/vuetify#4058. I copied the suggested code, tweaked it a bit, and now include it in a 'utilities.js' file that I import to any component that will open a modal.

;(function() {
  // make vuetify dialogs (x5 modals) movable
  const d = {}
  document.addEventListener('mousedown', e => {
    const closestDialog = e.target.closest('.x5-m-modal')
    const closestHeader = e.target.closest('.x5-m-header')
    if (e.button === 0 && closestHeader != null) {
      // element which can be used to move element
      d.el = closestDialog // element which should be moved
      d.mouseStartX = e.clientX
      d.mouseStartY = e.clientY
      d.elStartX = d.el.getBoundingClientRect().left
      d.elStartY = d.el.getBoundingClientRect().top
      d.el.style.position = 'fixed'
      d.el.style.margin = 0
      d.oldTransition = d.el.style.transition
      d.el.style.transition = 'none'
    }
  })
  document.addEventListener('mousemove', e => {
    if (d.el === undefined) return
    //david added the following line which allows the otherwise 'centered' modal to be moved precisely
    d.el.style.transform = 'none'

    d.el.style.left = Math.min(Math.max(d.elStartX + e.clientX - d.mouseStartX, 0), window.innerWidth - d.el.getBoundingClientRect().width) + 'px'
    d.el.style.top = Math.min(Math.max(d.elStartY + e.clientY - d.mouseStartY, 0), window.innerHeight - d.el.getBoundingClientRect().height) + 'px'
  })
  document.addEventListener('mouseup', () => {
    if (d.el === undefined) return
    d.el.style.transition = d.oldTransition
    d.el = undefined
  })
  setInterval(() => {
    // prevent out of bounds
    //example:  user drags modal to bottom of screen. User then inputs data into a text field on form within the modal
    //that results in the modal 'growing' downwards. Without this code, the bottom of the modal would extend out of
    //bounds; with this code the top of the modal is re-set so that the entire modal is showing.
    const dialog = document.querySelector('.x5-m-modal')
    if (dialog === null) return
    //this first line is probably not needed since users cannot cause modals to 'grow' wider, though, there could be
    //edge cases where the developer allows users to toggle to a wider view, thus possibly overflowing to the left or right
    dialog.style.left = Math.min(parseInt(dialog.style.left), window.innerWidth - dialog.getBoundingClientRect().width) + 'px'
    dialog.style.top = Math.min(parseInt(dialog.style.top), window.innerHeight - dialog.getBoundingClientRect().height) + 'px'
  }, 100)
})()

I also added a global style to App.vue which allows the cursor to change to an open hand (grab) when hovering over a modal's header, and then a 'clenched hand' (grabbing) when dragging the header:

<style>
.x5-m-header {
  cursor: grab;
}

.x5-m-header--active {
  cursor: grabbing;
}
</style>

No Buttons Animation

When a modal is set to have no buttons, as it appears the button row can be seen to collapses.

Add padding control to modal window

While in most cases the padding is fine, in some cases it is difficult to change the content padding so you end up with both being padded.

A no-padding prop or something would be useful.

Code splitting registration causes delay when opened

When a modal is registered via the code splitting method:

    this.$x5.registerModal('login', () => import('./modals/Login.vue'))

there is a slight delay before any activity takes place.
Ideally there should be a loading spinner to indicate the code is being downloaded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.