a62527776a / vue-floating-action-button

Floating Action Button for Vue based on Material Design
MIT License
170 stars 32 forks source link

Spacing issue #29

Closed ciops closed 3 years ago

ciops commented 3 years ago

Hey, there's a spacing issue on the first element when using "big" size. It also affects custom spacing options.

image

a62527776a commented 3 years ago

Thanks for your feedback!

<vue-fab 
      size="big"
      :globalOptions="{spacing: 50,delay: 0.1}" // Please try to increase the line
/>

If it doesn't work, please send me a code snippet.

thank you!

ciops commented 3 years ago

I've created a new Vue project just to be sure there's no conflict with existing code, problem persists:

image

Changing the spacing value doesn't affect the first element.

image

My code:

<template>
    <vue-fab 
        icon="menu" 
        size="big" 
        :scrollAutoHide="false" 
        :globalOptions="{ spacing: 50, delay: 0.05 }" 
        :mainBtnColor="mainBtnColor" 
        >
        <!-- :style="{ transform: 'translateX(10px)' }" -->
        <fab-item 
            v-for="(item, idx) in menu"
            :idx="idx"
            :key="idx"
            :title="item.title"
            :color="item.color"
            :icon="item.icon"
            @clickItem="navigateTo" 
            />
    </vue-fab>
</template>

<script>
export default {
    name: "FloatingNavigation",
    data () {
        return {
            menu: [
                {
                    idx: 0,
                    title: 'actionable',
                    icon: 'whatshot',
                    color: '#ff9900',
                    titleColor: '#fff',
                    titleBgColor: '#000',
                },
                {
                    idx: 1,
                    title: 'assets',
                    icon: 'savings',
                    color: '#729DCB'
                },
                {
                    idx: 2,
                    title: 'stats',
                    icon: 'analytics',
                    color: '#729DCB'
                },
                {
                    idx: 3,
                    title: 'profile',
                    icon: 'perm_identity',
                    color: '#729DCB'
                }
            ],
            mainBtnColor: '#729DCB'
        }
    },
    methods: {
        navigateTo: function (item) {
            return;
        },

    }
}
</script>

Awesome work on this project, love it!

a62527776a commented 3 years ago

thank you! I missed this situation. This problem is fixed in the latest @0.7.9 version! You can check the latest situation in https://vue-fab.github.io/!

企业微信截图_b6b76853-0677-4d1e-9a25-3592d76faea9
ciops commented 3 years ago

Works, thank you so much, really appreciated!

I would suggest using the spacing attribute to define the space between elements (excluding their size). This way, the elements are evenly spaced out (including the first one) in any context. Something like this:

let itemSize = 32;
if (this.$parent.size == 'big') {
    itemSize = 38;
} else if (this.$parent.size == 'small') {
    itemSize = 26;
}
defaultY = -((this.idx+1) * (itemSize + this.$parent.globalOptions.spacing)) + 'px';